1 Kaplan-Meier Analysis.

# Load the data
# Load the data
ClinicData <- read.csv("/Users/sultanalharbi/Library/CloudStorage/OneDrive-Personal/Projects/Thesis_Chapters/Chapter 2 (Prognostic Indicators for HCC)/ICI_TKI_Ram_Sul_Mat_2025-01-29_Final.csv")

# Set the options to limit the output
options(max.print=100
       )

# Print the summary of the data
summary(ClinicData)
##    Radio_ID         Lab.ID_Baseline    Lab.ID_Baseline2   Specific.Treatment
##  Length:134         Length:134         Length:134         Length:134        
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##  Treatment_Class       Gender           Gender_Rank         Age       
##  Length:134         Length:134         Min.   :1.000   Min.   :37.00  
##  Class :character   Class :character   1st Qu.:1.000   1st Qu.:63.00  
##  Mode  :character   Mode  :character   Median :1.000   Median :70.50  
##   Aetiology             CTP                  PS          Cirrhosis        
##  Length:134         Length:134         Min.   :0.0000   Length:134        
##  Class :character   Class :character   1st Qu.:0.0000   Class :character  
##  Mode  :character   Mode  :character   Median :1.0000   Mode  :character  
##  Best_Responsce          tMAD          cfDNA_Level_Baseline_ng_ml
##  Length:134         Min.   :0.005713   Min.   :   20.0           
##  Class :character   1st Qu.:0.010032   1st Qu.:  439.2           
##  Mode  :character   Median :0.013982   Median : 1010.0           
##      BCLC                AFP               PVT           
##  Length:134         Min.   :     1.0   Length:134        
##  Class :character   1st Qu.:     4.0   Class :character  
##  Mode  :character   Median :    35.5   Mode  :character  
##  Tumour.largest.size..cm. Number.of.Nodules     Time_OS         OS_Status     
##  Min.   : 1.000           Length:134         Min.   : 1.520   Min.   :0.0000  
##  1st Qu.: 3.000           Class :character   1st Qu.: 7.183   1st Qu.:0.2500  
##  Median : 4.650           Mode  :character   Median :14.485   Median :1.0000  
##     Time_PFS        PFS_Status     DELFI_Baseline   DELFI_Baseline_Rank
##  Min.   : 0.330   Min.   :0.0000   Min.   :0.1240   Min.   :0.0000     
##  1st Qu.: 3.240   1st Qu.:1.0000   1st Qu.:0.2313   1st Qu.:0.0000     
##  Median : 7.550   Median :1.0000   Median :0.2840   Median :0.0000     
##  Tumour_Fraction_ichorCNA_Baseline    TF_Rank      
##  Min.   :0.00900                   Min.   :0.0000  
##  1st Qu.:0.01300                   1st Qu.:0.0000  
##  Median :0.04100                   Median :0.0000  
##  [ reached 'max' / getOption("max.print") -- omitted 3 rows ]

1.1 Overall Survival (OS)

Here is the Kaplan-Meier curve for the overall survival (OS) of whole patient cohort with HCC treated with Systemic therapies.

# Fit the survival model
Whole_Cohort_OS <- survfit(Surv(Time_OS, OS_Status) ~ 1, data = ClinicData, conf.type = "log-log")
summary_data_Whole_Cohort_OS <- summary(Whole_Cohort_OS)
Whole_Cohort_median_OS <- summary_data_Whole_Cohort_OS$table['median']
Whole_Cohort_lower_OS_ci <- summary_data_Whole_Cohort_OS$table['0.95LCL']
Whole_Cohort_upper_OS_ci <- summary_data_Whole_Cohort_OS$table['0.95UCL']

# Create the survival plot
OS_plot <- ggsurvplot(Whole_Cohort_OS,
                      conf.int = TRUE, # add confidence intervals
                      pval = TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, # show method for p-value
                      pval.size = 4, # p-value text size
                      test.for.trend = FALSE,
                      risk.table = TRUE, # show a risk table below the plot
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", # horizontal/vertical line at median survival
                      tables.y.text.col = TRUE,
                      fontsize = 5,
                      risk.table.title = "Number at risk", # risk table title
                      title = NULL, # plot title
                      risk.table.height = 0.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab = "Time, months",
                      ylab = "OS Probability",
                      axes.offset = TRUE,
                      surv.plot.height = 1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title = 15)

# Annotate the median OS and confidence interval
OS_plot$plot <- OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.5, 
                 label = paste("Median OS: ", round(Whole_Cohort_median_OS, 2), " months\n",
                               "95% CI: ", round(Whole_Cohort_lower_OS_ci, 2),"-", round(Whole_Cohort_upper_OS_ci, 2))),
             size = 6, hjust = 0, vjust = 0.5)
             
# Print the plot in the R Markdown document
print(OS_plot)

# Save the plot as a high-resolution PNG
png("Whole_Cohort_OS_TKI_ICI.png", width = 8, height = 6, units = "in", res = 500)
print(OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.2 Pregression-Free survival (PFS)

Here is the Kaplan-Meier curve for the Pregression-Free survival (PFS) of whole patient cohort with HCC treated with Systemic therapies.

# Fit the survival model
Whole_Cohort_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ 1, data = ClinicData, conf.type = "log-log")
summary_data_Whole_Cohort_PFS <- summary(Whole_Cohort_PFS)
Whole_Cohort_median_PFS <- summary_data_Whole_Cohort_PFS$table['median']
Whole_Cohort_lower_PFS_ci <- summary_data_Whole_Cohort_PFS$table['0.95LCL']
Whole_Cohort_upper_PFS_ci <- summary_data_Whole_Cohort_PFS$table['0.95UCL']

# Create the survival plot
PFS_plot <- ggsurvplot(Whole_Cohort_PFS,
                      conf.int = TRUE, # add confidence intervals
                      pval = TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, # show method for p-value
                      pval.size = 4, # p-value text size
                      test.for.trend = FALSE,
                      risk.table = TRUE, # show a risk table below the plot
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", # horizontal/vertical line at median survival
                      tables.y.text.col = TRUE,
                      fontsize = 5,
                      risk.table.title = "Number at risk", # risk table title
                      title = NULL, # plot title
                      risk.table.height = 0.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab = "Time, months",
                      ylab = "PFS Probability",
                      axes.offset = TRUE,
                      surv.plot.height = 1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title = 15)

# Annotate the median PFS and confidence interval
PFS_plot$plot <- PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.5, 
                 label = paste("Median PFS: ", round(Whole_Cohort_median_PFS, 2), " months\n",
                               "95% CI: ", round(Whole_Cohort_lower_PFS_ci, 2),"-", round(Whole_Cohort_upper_PFS_ci, 2))),
             size = 6, hjust = 0, vjust = 0.5)

# Print the plot in the R Markdown document
print(PFS_plot)

# Save the plot as a high-resolution PNG
png("Whole_Cohort_PFS_TKI_ICI.png", width = 8, height = 6, units = "in", res = 300)
print(PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.3 BCLC class as predictor for OS

# Fit the survival model for OS
BCLC_OS <- survfit(Surv(Time_OS, OS_Status) ~ BCLC, data = ClinicData, conf.type = "log-log")
summary_data_BCLC_OS <- summary(BCLC_OS)

# Extract median OS and confidence intervals for each group
BCLC_median_OS_B <- summary_data_BCLC_OS$time[summary_data_BCLC_OS$strata == "BCLC=B" & summary_data_BCLC_OS$time == summary_data_BCLC_OS$table["BCLC=B", "median"]]
BCLC_lower_OS_ci_B <- summary_data_BCLC_OS$table["BCLC=B", "0.95LCL"]
BCLC_upper_OS_ci_B <- summary_data_BCLC_OS$table["BCLC=B", "0.95UCL"]

BCLC_median_OS_C <- summary_data_BCLC_OS$time[summary_data_BCLC_OS$strata == "BCLC=C" & summary_data_BCLC_OS$time == summary_data_BCLC_OS$table["BCLC=C", "median"]]
BCLC_lower_OS_ci_C <- summary_data_BCLC_OS$table["BCLC=C", "0.95LCL"]
BCLC_upper_OS_ci_C <- summary_data_BCLC_OS$table["BCLC=C", "0.95UCL"]

# Create the survival plot
BCLC_OS_plot <- ggsurvplot(BCLC_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(50, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(50, 0.20),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("B", "C"), # change group labels
                             tables.col = "BCLC",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "BCLC",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for group
BCLC_OS_plot$plot <- BCLC_OS_plot$plot + 
  geom_label(aes(x = 37, y = 0.60, 
                 label = paste("C \nMedian OS: ", round(BCLC_median_OS_C, 2), " months\n",
                               "95% CI: ", round(BCLC_lower_OS_ci_C, 2), "-", round(BCLC_upper_OS_ci_C, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 37, y = 0.90, 
                 label = paste("B \nMedian OS: ", round(BCLC_median_OS_B, 2), " months\n",
                               "95% CI: ", round(BCLC_lower_OS_ci_B, 2), "-", round(BCLC_upper_OS_ci_B, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(BCLC_OS_plot)

# High-resolution plot saving
png("BCLC_OS_TKI_ICI.png", width = 8, height = 6, units = "in", res = 500)
print(BCLC_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.4 BCLC class as predictor for PFS

# Fit the survival model for PFS
BCLC_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ BCLC, data = ClinicData, conf.type = "log-log")
summary_data_BCLC_PFS <- summary(BCLC_PFS)

# Extract median PFS and confidence intervals for each group
BCLC_median_PFS_B <- summary_data_BCLC_PFS$time[summary_data_BCLC_PFS$strata == "BCLC=B" & summary_data_BCLC_PFS$time == summary_data_BCLC_PFS$table["BCLC=B", "median"]]
BCLC_lower_PFS_ci_B <- summary_data_BCLC_PFS$table["BCLC=B", "0.95LCL"]
BCLC_upper_PFS_ci_B <- summary_data_BCLC_PFS$table["BCLC=B", "0.95UCL"]

BCLC_median_PFS_C <- summary_data_BCLC_PFS$time[summary_data_BCLC_PFS$strata == "BCLC=C" & summary_data_BCLC_PFS$time == summary_data_BCLC_PFS$table["BCLC=C", "median"]]
BCLC_lower_PFS_ci_C <- summary_data_BCLC_PFS$table["BCLC=C", "0.95LCL"]
BCLC_upper_PFS_ci_C <- summary_data_BCLC_PFS$table["BCLC=C", "0.95UCL"]

# Create the survival plot
BCLC_PFS_plot <- ggsurvplot(BCLC_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(30, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(30, 0.20),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("B", "C"), # change group labels
                             tables.col = "BCLC",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "BCLC",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for group
BCLC_PFS_plot$plot <- BCLC_PFS_plot$plot + 
  geom_label(aes(x = 24, y = 0.60, 
                 label = paste("C \nMedian PFS: ", round(BCLC_median_PFS_C, 2), " months\n",
                               "95% CI: ", round(BCLC_lower_PFS_ci_C, 2), "-", round(BCLC_upper_PFS_ci_C, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 24, y = 0.90, 
                 label = paste("B \nMedian PFS: ", round(BCLC_median_PFS_B, 2), " months\n",
                               "95% CI: ", round(BCLC_lower_PFS_ci_B, 2), "-", round(BCLC_upper_PFS_ci_B, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(BCLC_PFS_plot)

# High-resolution plot saving
png("BCLC_PFS_TKI_ICI.png", width = 8, height = 6, units = "in", res = 500)
print(BCLC_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.5 CTP class as predictor for OS

# Fit the survival model for OS
CTP_OS <- survfit(Surv(Time_OS, OS_Status) ~ CTP, data = ClinicData, conf.type = "log-log")
summary_data_CTP_OS <- summary(CTP_OS)

# Extract median OS and confidence intervals for each group
CTP_median_OS_A <- summary_data_CTP_OS$table["CTP=A" , "median"]
CTP_lower_OS_ci_A <- summary_data_CTP_OS$table["CTP=A", "0.95LCL"]
CTP_upper_OS_ci_A <- summary_data_CTP_OS$table["CTP=A", "0.95UCL"]

CTP_median_OS_B <- summary_data_CTP_OS$table["CTP=B", "median"]
CTP_lower_OS_ci_B <- summary_data_CTP_OS$table["CTP=B", "0.95LCL"]
CTP_upper_OS_ci_B <- summary_data_CTP_OS$table["CTP=B", "0.95UCL"]

# Create the survival plot
CTP_OS_plot <- ggsurvplot(CTP_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(40, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(40, 0.20),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("A", "B"), # change group labels
                             tables.col = "CTP",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "CTP Class",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for group
CTP_OS_plot$plot <- CTP_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.60, 
                 label = paste("B \nMedian OS: ", round(CTP_median_OS_B, 2), " months\n",
                               "95% CI: ", round(CTP_lower_OS_ci_B, 2), "-", round(CTP_upper_OS_ci_B, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.90, 
                 label = paste("A \nMedian OS: ", round(CTP_median_OS_A, 2), " months\n",
                               "95% CI: ", round(CTP_lower_OS_ci_A, 2), "-", round(CTP_upper_OS_ci_A, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(CTP_OS_plot)

# High-resolution plot saving
png("CTP_OS_TKI_ICI.png", width = 8, height = 6, units = "in", res = 500)
print(CTP_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.6 CTP class as predictor for PFS

# Fit the survival model for PFS
CTP_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ CTP, data = ClinicData, conf.type = "log-log")
summary_data_CTP_PFS <- summary(CTP_PFS)

# Extract median PFS and confidence intervals for each group
CTP_median_PFS_A <- summary_data_CTP_PFS$table["CTP=A" , "median"]
CTP_lower_PFS_ci_A <- summary_data_CTP_PFS$table["CTP=A", "0.95LCL"]
CTP_upper_PFS_ci_A <- summary_data_CTP_PFS$table["CTP=A", "0.95UCL"]

CTP_median_PFS_B <- summary_data_CTP_PFS$table["CTP=B", "median"]
CTP_lower_PFS_ci_B <- summary_data_CTP_PFS$table["CTP=B", "0.95LCL"]
CTP_upper_PFS_ci_B <- summary_data_CTP_PFS$table["CTP=B", "0.95UCL"]

# Create the survival plot
CTP_PFS_plot <- ggsurvplot(
  CTP_PFS,
  conf.int = FALSE,
  pval = TRUE,
  pval.method = TRUE,
  pval.size = 4,
  pval.method.coord = c(30, 0.35), # <- move the "log-rank" method label here
  pval.coord = c(30, 0.25),       # <- move the log-rank p-value here (x, y)
  test.for.trend = FALSE,
  risk.table = TRUE,
  cumevents = FALSE,
  cumcensor = FALSE,
  surv.median.line = "hv",
  legend.labs = c("A","B"),
  tables.col = "CTP",
  tables.y.text.col = TRUE,
  fontsize = 5,
  legend.title = "CTP Class",
  risk.table.title = "Number at risk",
  title = NULL,
  risk.table.height = 0.30,
  add.all = FALSE,
  combine = FALSE,
  xlab = "Time, months",
  ylab = "PFS Probability",
  axes.offset = TRUE,
  surv.plot.height = 1,
  font.x = 15, font.y = 15, font.legend.title = 15
)

# Annotate the median PFS and confidence interval for group
CTP_PFS_plot$plot <- CTP_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.70, 
                 label = paste("B \nMedian PFS: ", round(CTP_median_PFS_B, 2), " months\n",
                               "95% CI: ", round(CTP_lower_PFS_ci_B, 2), "-", round(CTP_upper_PFS_ci_B, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.98, 
                 label = paste("A \nMedian PFS: ", round(CTP_median_PFS_A, 2), " months\n",
                               "95% CI: ", round(CTP_lower_PFS_ci_A, 2), "-", round(CTP_upper_PFS_ci_A, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(CTP_PFS_plot)

# High-resolution plot saving
png("CTP_PFS_TKI_ICI.png", width = 8, height = 6, units = "in", res = 500)
print(CTP_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.7 ECOG-PS as predictor for OS

# Fit the survival model for OS
PS_OS <- survfit(Surv(Time_OS, OS_Status) ~ PS, data = ClinicData, conf.type = "log-log")
summary_data_PS_OS <- summary(PS_OS)

# Extract median OS and confidence intervals for each group
PS_median_OS_0 <- summary_data_PS_OS$table["PS=0" , "median"]
PS_lower_OS_ci_0 <- summary_data_PS_OS$table["PS=0", "0.95LCL"]
PS_upper_OS_ci_0 <- summary_data_PS_OS$table["PS=0", "0.95UCL"]

PS_median_OS_1 <- summary_data_PS_OS$table["PS=1", "median"]
PS_lower_OS_ci_1 <- summary_data_PS_OS$table["PS=1", "0.95LCL"]
PS_upper_OS_ci_1 <- summary_data_PS_OS$table["PS=1", "0.95UCL"]

PS_median_OS_2 <- summary_data_PS_OS$table["PS=2", "median"]
PS_lower_OS_ci_2 <- summary_data_PS_OS$table["PS=2", "0.95LCL"]
PS_upper_OS_ci_2 <- summary_data_PS_OS$table["PS=2", "0.95UCL"]

# Create the survival plot
PS_OS_plot <- ggsurvplot(PS_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(45, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(45, 0.25),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("0", "1", "2"), # change group labels
                             tables.col = "PS",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "ECOG-PS",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.20,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for group
PS_OS_plot$plot <- PS_OS_plot$plot + 
  geom_label(aes(x = 43, y = 0.90, 
                 label = paste("0 \nMedian OS: ", round(PS_median_OS_0, 2), " months\n",
                               "95% CI: ", round(PS_lower_OS_ci_0, 2), "-", round(PS_upper_OS_ci_0, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 43, y = 0.70, 
                 label = paste("1 \nMedian OS: ", round(PS_median_OS_1, 2), " months\n",
                               "95% CI: ", round(PS_lower_OS_ci_1, 2), "-", round(PS_upper_OS_ci_1, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BA38") +
  geom_label(aes(x = 43, y = 0.50, 
                 label = paste("2 \nMedian OS: ", round(PS_median_OS_2, 2), " months\n",
                               "95% CI: ", round(PS_lower_OS_ci_2, 2), "-", round(PS_upper_OS_ci_2, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#6495ED")

# Print the plot in the R Markdown document
print(PS_OS_plot)

# High-resolution plot saving
png("PS_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(PS_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.8 ECOG-PS as predictor for PFS

# Fit the survival model for PFS
PS_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ PS, data = ClinicData, conf.type = "log-log")
summary_data_PS_PFS <- summary(PS_PFS)

# Extract median PFS and confidence intervals for each group
PS_median_PFS_0 <- summary_data_PS_PFS$table["PS=0" , "median"]
PS_lower_PFS_ci_0 <- summary_data_PS_PFS$table["PS=0", "0.95LCL"]
PS_upper_PFS_ci_0 <- summary_data_PS_PFS$table["PS=0", "0.95UCL"]

PS_median_PFS_1 <- summary_data_PS_PFS$table["PS=1", "median"]
PS_lower_PFS_ci_1 <- summary_data_PS_PFS$table["PS=1", "0.95LCL"]
PS_upper_PFS_ci_1 <- summary_data_PS_PFS$table["PS=1", "0.95UCL"]

PS_median_PFS_2 <- summary_data_PS_PFS$table["PS=2", "median"]
PS_lower_PFS_ci_2 <- summary_data_PS_PFS$table["PS=2", "0.95LCL"]
PS_upper_PFS_ci_2 <- summary_data_PS_PFS$table["PS=2", "0.95UCL"]

# Create the survival plot
PS_PFS_plot <- ggsurvplot(PS_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(25, 0.22), # <- move the "log-rank" method label here
                             pval.coord = c(25, 0.18), 
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("0", "1", "2"), # change group labels
                             tables.col = "PS",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "ECOG-PS",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.20,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for group
PS_PFS_plot$plot <- PS_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.80, 
                 label = paste("0 \nMedian PFS: ", round(PS_median_PFS_0, 2), " months\n",
                               "95% CI: ", round(PS_lower_PFS_ci_0, 2), "-", round(PS_upper_PFS_ci_0, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 25, y = 0.60, 
                 label = paste("1 \nMedian PFS: ", round(PS_median_PFS_1, 2), " months\n",
                               "95% CI: ", round(PS_lower_PFS_ci_1, 2), "-", round(PS_upper_PFS_ci_1, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BA38") +
  geom_label(aes(x = 25, y = 0.40, 
                 label = paste("2 \nMedian PFS: ", round(PS_median_PFS_2, 2), " months\n",
                               "95% CI: ", round(PS_lower_PFS_ci_2, 2), "-", round(PS_upper_PFS_ci_2, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#6495ED")

# Print the plot in the R Markdown document
print(PS_PFS_plot)

# High-resolution plot saving
png("PS_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(PS_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.9 HAP Class as predictor for OS

# Fit the survival model for OS
HAP_OS <- survfit(Surv(Time_OS, OS_Status) ~ HAP_class, data = ClinicData)
## Error in eval(predvars, data, env): object 'HAP_class' not found
summary_data_HAP_OS <- summary(HAP_OS)
## Error: object 'HAP_OS' not found
# Extract median OS and confidence intervals for each group
HAP_median_OS_A <- summary_data_HAP_OS$table["HAP_class=A" , "median"]
## Error: object 'summary_data_HAP_OS' not found
HAP_lower_OS_ci_A <- summary_data_HAP_OS$table["HAP_class=A", "0.95LCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_upper_OS_ci_A <- summary_data_HAP_OS$table["HAP_class=A", "0.95UCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_median_OS_B <- summary_data_HAP_OS$table["HAP_class=B" , "median"]
## Error: object 'summary_data_HAP_OS' not found
HAP_lower_OS_ci_B <- summary_data_HAP_OS$table["HAP_class=B", "0.95LCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_upper_OS_ci_B <- summary_data_HAP_OS$table["HAP_class=B", "0.95UCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_median_OS_C <- summary_data_HAP_OS$table["HAP_class=C" , "median"]
## Error: object 'summary_data_HAP_OS' not found
HAP_lower_OS_ci_C <- summary_data_HAP_OS$table["HAP_class=C", "0.95LCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_upper_OS_ci_C <- summary_data_HAP_OS$table["HAP_class=C", "0.95UCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_median_OS_D <- summary_data_HAP_OS$table["HAP_class=D" , "median"]
## Error: object 'summary_data_HAP_OS' not found
HAP_lower_OS_ci_D <- summary_data_HAP_OS$table["HAP_class=D", "0.95LCL"]
## Error: object 'summary_data_HAP_OS' not found
HAP_upper_OS_ci_D <- summary_data_HAP_OS$table["HAP_class=D", "0.95UCL"]
## Error: object 'summary_data_HAP_OS' not found
# Create the survival plot
HAP_OS_plot <- ggsurvplot(HAP_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("A", "B", "C", "D"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "HAP Class",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.20,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15,
                             palette = c("#F8766D", "#00BA38", "#619CFF", "#D161C4")) # Match line colors
## Error: object 'HAP_OS' not found
# Annotate the median OS and confidence interval for each group
HAP_OS_plot$plot <- HAP_OS_plot$plot + 
  annotate("label", x = 48, y = 1, 
           label = paste("A\nMedian OS: ", round(HAP_median_OS_A, 2), " months\n",
                         "95% CI: ", round(HAP_lower_OS_ci_A, 2), "-", round(HAP_upper_OS_ci_A, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  annotate("label", x = 48, y = 0.80, 
           label = paste("B\nMedian OS: ", round(HAP_median_OS_B, 2), " months\n",
                         "95% CI: ", round(HAP_lower_OS_ci_B, 2), "-", round(HAP_upper_OS_ci_B, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BA38") +
  annotate("label", x = 48, y = 0.60, 
           label = paste("C\nMedian OS: ", round(HAP_median_OS_C, 2), " months\n",
                         "95% CI: ", round(HAP_lower_OS_ci_C, 2), "-", round(HAP_upper_OS_ci_C, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#619CFF") +
  annotate("label", x = 48, y = 0.40, 
           label = paste("D\nMedian OS: ", round(HAP_median_OS_D, 2), " months\n",
                         "95% CI: ", round(HAP_lower_OS_ci_D, 2), "-", round(HAP_upper_OS_ci_D, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#D161C4")
## Error: object 'HAP_OS_plot' not found
# Print the plot in the R Markdown document
print(HAP_OS_plot)
## Error: object 'HAP_OS_plot' not found
# High-resolution plot saving
png("HAP_OS_TKIs.png", width = 10, height = 8, units = "in", res = 300)
print(HAP_OS_plot)
## Error: object 'HAP_OS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.10 HAP Class as predictor for PFS

# Fit the survival model for PFS
HAP_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ HAP_class, data = ClinicData)
## Error in eval(predvars, data, env): object 'HAP_class' not found
summary_data_HAP_PFS <- summary(HAP_PFS)
## Error: object 'HAP_PFS' not found
# Extract median OS and confidence intervals for each group
HAP_median_PFS_A <- summary_data_HAP_PFS$table["HAP_class=A" , "median"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_lower_PFS_ci_A <- summary_data_HAP_PFS$table["HAP_class=A", "0.95LCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_upper_PFS_ci_A <- summary_data_HAP_PFS$table["HAP_class=A", "0.95UCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_median_PFS_B <- summary_data_HAP_PFS$table["HAP_class=B" , "median"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_lower_PFS_ci_B <- summary_data_HAP_PFS$table["HAP_class=B", "0.95LCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_upper_PFS_ci_B <- summary_data_HAP_PFS$table["HAP_class=B", "0.95UCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_median_PFS_C <- summary_data_HAP_PFS$table["HAP_class=C" , "median"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_lower_PFS_ci_C <- summary_data_HAP_PFS$table["HAP_class=C", "0.95LCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_upper_PFS_ci_C <- summary_data_HAP_PFS$table["HAP_class=C", "0.95UCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_median_PFS_D <- summary_data_HAP_PFS$table["HAP_class=D" , "median"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_lower_PFS_ci_D <- summary_data_HAP_PFS$table["HAP_class=D", "0.95LCL"]
## Error: object 'summary_data_HAP_PFS' not found
HAP_upper_PFS_ci_D <- summary_data_HAP_PFS$table["HAP_class=D", "0.95UCL"]
## Error: object 'summary_data_HAP_PFS' not found
# Create the survival plot
HAP_PFS_plot <- ggsurvplot(HAP_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("A", "B", "C", "D"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "HAP Class",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.20,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15,
                             palette = c("#F8766D", "#00BA38", "#619CFF", "#D161C4")) # Match line colors
## Error: object 'HAP_PFS' not found
# Annotate the median PFS and confidence interval for each group
HAP_PFS_plot$plot <- HAP_PFS_plot$plot + 
  annotate("label", x = 30, y = 1, 
           label = paste("A\nMedian PFS: ", round(HAP_median_PFS_A, 2), " months\n",
                         "95% CI: ", round(HAP_lower_PFS_ci_A, 2), "-", round(HAP_upper_PFS_ci_A, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  annotate("label", x = 30, y = 0.80, 
           label = paste("B\nMedian PFS: ", round(HAP_median_PFS_B, 2), " months\n",
                         "95% CI: ", round(HAP_lower_PFS_ci_B, 2), "-", round(HAP_upper_PFS_ci_B, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BA38") +
  annotate("label", x = 30, y = 0.60, 
           label = paste("C\nMedian PFS: ", round(HAP_median_PFS_C, 2), " months\n",
                         "95% CI: ", round(HAP_lower_PFS_ci_C, 2), "-", round(HAP_upper_PFS_ci_C, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#619CFF") +
  annotate("label", x = 30, y = 0.40, 
           label = paste("D\nMedian PFS: ", round(HAP_median_PFS_D, 2), " months\n",
                         "95% CI: ", round(HAP_lower_PFS_ci_D, 2), "-", round(HAP_upper_PFS_ci_D, 2)), 
           size = 4, hjust = 0, vjust = 1, color = "black", fill = "#D161C4")
## Error: object 'HAP_PFS_plot' not found
# Print the plot in the R Markdown document
print(HAP_PFS_plot)
## Error: object 'HAP_PFS_plot' not found
# High-resolution plot saving
png("HAP_PFS_TKIs.png", width = 11, height = 8, units = "in", res = 300)
print(HAP_PFS_plot)
## Error: object 'HAP_PFS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.11 Cirrhosis as predictor for OS

#### Cirrhosis Analysis
###For Cirrhosis survival curve the right hand side should be ~ Cirrhosis
Cirrhosis_OS = survfit(Surv(Time_OS, OS_Status) ~ Cirrhosis , data = ClinicData)
summary_data_Cirrhosis_OS <- summary(Cirrhosis_OS)
# Extract median OS and confidence intervals for each group
Cirrhosis_median_OS_NO <- summary_data_Cirrhosis_OS$table["Cirrhosis=NO", "median"]
Cirrhosis_lower_OS_ci_NO <- summary_data_Cirrhosis_OS$table["Cirrhosis=NO", "0.95LCL"]
Cirrhosis_upper_OS_ci_NO <- summary_data_Cirrhosis_OS$table["Cirrhosis=NO", "0.95UCL"]

Cirrhosis_median_OS_YES <- summary_data_Cirrhosis_OS$table["Cirrhosis=YES", "median"]
Cirrhosis_lower_OS_ci_YES <- summary_data_Cirrhosis_OS$table["Cirrhosis=YES", "0.95LCL"]
Cirrhosis_upper_OS_ci_YES <- summary_data_Cirrhosis_OS$table["Cirrhosis=YES", "0.95UCL"]


Cirrhosis_OS_plot <- ggsurvplot(Cirrhosis_OS,
                      conf.int=FALSE, # add confidence intervals
                      pval=TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, #corresponds to survival curves' comparison
                      pval.size= 4,# numeric value specifying the p-value text size. Default is 5.
                      test.for.trend = FALSE,
                      risk.table=TRUE,# show a risk table below the plot.
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", #for drawing a horizontal/vertical line at median survival.
                      legend.labs=c("No", "Yes"), # change group labels
                      tables.col = "strata",
                      tables.y.text.col=TRUE,
                      fontsize=5,
                      legend.title="Cirrhosis",  # add legend title
                      risk.table.title="Number at risk", #the title to be used for the risk table.
                      title=NULL, # add title to plot
                      risk.table.height=.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab="Time, months",
                      ylab="OS Probability",
                      axes.offset=TRUE,
                      surv.plot.height=1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title=15)
## Error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, : The length of legend.labs should be 3
# Annotate the median OS and confidence interval for group
Cirrhosis_OS_plot$plot <- Cirrhosis_OS_plot$plot + 
  geom_label(aes(x = 37, y = 0.60, 
                 label = paste("NO \nMedian OS: ", round(Cirrhosis_median_OS_NO, 2), " months\n",
                               "95% CI: ", round(Cirrhosis_lower_OS_ci_NO, 2), "-", round(Cirrhosis_upper_OS_ci_NO, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 37, y = 0.90,
                 label = paste("YES \nMedian OS: ", round(Cirrhosis_median_OS_YES, 2), " months\n",
                               "95% CI: ", round(Cirrhosis_lower_OS_ci_YES, 2), "-", round(Cirrhosis_upper_OS_ci_YES, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")
## Error: object 'Cirrhosis_OS_plot' not found
# Print the plot in the R Markdown document
print(Cirrhosis_OS_plot)
## Error: object 'Cirrhosis_OS_plot' not found
# High-resolution plot saving
png("Cirrhosis_OS_TKIs.png", width = 8, height = 6, units = "in", res = 300)
print(Cirrhosis_OS_plot)
## Error: object 'Cirrhosis_OS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.12 Cirrhosis as predictor for PFS

#### Cirrhosis Analysis
###For Cirrhosis survival curve the right hand side should be ~ Cirrhosis
Cirrhosis_PFS = survfit(Surv(Time_PFS, PFS_Status) ~ Cirrhosis , data = ClinicData)
summary_data_Cirrhosis_PFS <- summary(Cirrhosis_PFS)
# Extract median PFS and confidence intervals for each group
Cirrhosis_median_PFS_NO <- summary_data_Cirrhosis_PFS$table["Cirrhosis=NO", "median"]
Cirrhosis_lower_PFS_ci_NO <- summary_data_Cirrhosis_PFS$table["Cirrhosis=NO", "0.95LCL"]
Cirrhosis_upper_PFS_ci_NO <- summary_data_Cirrhosis_PFS$table["Cirrhosis=NO", "0.95UCL"]

Cirrhosis_median_PFS_YES <- summary_data_Cirrhosis_PFS$table["Cirrhosis=YES", "median"]
Cirrhosis_lower_PFS_ci_YES <- summary_data_Cirrhosis_PFS$table["Cirrhosis=YES", "0.95LCL"]
Cirrhosis_upper_PFS_ci_YES <- summary_data_Cirrhosis_PFS$table["Cirrhosis=YES", "0.95UCL"]


Cirrhosis_PFS_plot <- ggsurvplot(Cirrhosis_PFS,
                      conf.int=FALSE, # add confidence intervals
                      pval=TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, #corresponds to survival curves' comparison
                      pval.size= 4,# numeric value specifying the p-value text size. Default is 5.
                      test.for.trend = FALSE,
                      risk.table=TRUE,# show a risk table below the plot.
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", #for drawing a horizontal/vertical line at median survival.
                      legend.labs=c("No", "Yes"), # change group labels
                      tables.col = "strata",
                      tables.y.text.col=TRUE,
                      fontsize=5,
                      legend.title="Cirrhosis",  # add legend title
                      risk.table.title="Number at risk", #the title to be used for the risk table.
                      title=NULL, # add title to plot
                      risk.table.height=.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab="Time, months",
                      ylab="PFS Probability",
                      axes.offset=TRUE,
                      surv.plot.height=1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title=15)
## Error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, : The length of legend.labs should be 3
# Annotate the median PFS and confidence interval for group
Cirrhosis_PFS_plot$plot <- Cirrhosis_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.60, 
                 label = paste("NO \nMedian PFS: ", round(Cirrhosis_median_PFS_NO, 2), " months\n",
                               "95% CI: ", round(Cirrhosis_lower_PFS_ci_NO, 2), "-", round(Cirrhosis_upper_PFS_ci_NO, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 25, y = 0.90,
                 label = paste("YES \nMedian PFS: ", round(Cirrhosis_median_PFS_YES, 2), " months\n",
                               "95% CI: ", round(Cirrhosis_lower_PFS_ci_YES, 2), "-", round(Cirrhosis_upper_PFS_ci_YES, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")
## Error: object 'Cirrhosis_PFS_plot' not found
# Print the plot in the R Markdown document
print(Cirrhosis_PFS_plot)
## Error: object 'Cirrhosis_PFS_plot' not found
# High-resolution plot saving
png("Cirrhosis_PFS_TKIs.png", width = 8, height = 6, units = "in", res = 300)
print(Cirrhosis_PFS_plot)
## Error: object 'Cirrhosis_PFS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.13 Viral vs. Non Viral aetiology as predictor for OS

#### Viral_Not_Viral Analysis
###For Viral_Not_Viral survival curve the right hand side should be ~ Viral_Not_Viral
Viral_Not_Viral_OS = survfit(Surv(Time_OS, OS_Status) ~ Viral_Not_Viral , data = ClinicData)
## Error in eval(predvars, data, env): object 'Viral_Not_Viral' not found
summary_data_Viral_Not_Viral_OS <- summary(Viral_Not_Viral_OS)
## Error: object 'Viral_Not_Viral_OS' not found
# Extract median OS and confidence intervals for each group
Viral_Not_Viral_median_OS_Non_viral <- summary_data_Viral_Not_Viral_OS$table["Viral_Not_Viral=Non-viral", "median"]
## Error: object 'summary_data_Viral_Not_Viral_OS' not found
Viral_Not_Viral_lower_OS_ci_Non_viral <- summary_data_Viral_Not_Viral_OS$table["Viral_Not_Viral=Non-viral", "0.95LCL"]
## Error: object 'summary_data_Viral_Not_Viral_OS' not found
Viral_Not_Viral_upper_OS_ci_Non_viral <- summary_data_Viral_Not_Viral_OS$table["Viral_Not_Viral=Non-viral", "0.95UCL"]
## Error: object 'summary_data_Viral_Not_Viral_OS' not found
Viral_Not_Viral_median_OS_Viral <- summary_data_Viral_Not_Viral_OS$table["Viral_Not_Viral=Viral", "median"]
## Error: object 'summary_data_Viral_Not_Viral_OS' not found
Viral_Not_Viral_lower_OS_ci_Viral <- summary_data_Viral_Not_Viral_OS$table["Viral_Not_Viral=Viral", "0.95LCL"]
## Error: object 'summary_data_Viral_Not_Viral_OS' not found
Viral_Not_Viral_upper_OS_ci_Viral <- summary_data_Viral_Not_Viral_OS$table["Viral_Not_Viral=Viral", "0.95UCL"]
## Error: object 'summary_data_Viral_Not_Viral_OS' not found
Viral_Not_Viral_OS_plot <- ggsurvplot(Viral_Not_Viral_OS,
                      conf.int=FALSE, # add confidence intervals
                      pval=TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, #corresponds to survival curves' comparison
                      pval.size= 4,# numeric value specifying the p-value text size. Default is 5.
                      test.for.trend = FALSE,
                      risk.table=TRUE,# show a risk table below the plot.
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", #for drawing a horizontal/vertical line at median survival.
                      legend.labs=c("Non viral", "Viral"), # change group labels
                      tables.col = "strata",
                      tables.y.text.col=TRUE,
                      fontsize=5,
                      legend.title="Aetiology",  # add legend title
                      risk.table.title="Number at risk", #the title to be used for the risk table.
                      title=NULL, # add title to plot
                      risk.table.height=.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab="Time, months",
                      ylab="OS Probability",
                      axes.offset=TRUE,
                      surv.plot.height=1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title=15)
## Error: object 'Viral_Not_Viral_OS' not found
# Annotate the median OS and confidence interval for group
Viral_Not_Viral_OS_plot$plot <- Viral_Not_Viral_OS_plot$plot + 
  geom_label(aes(x = 37, y = 0.60, 
                 label = paste("Non viral \nMedian OS: ", round(Viral_Not_Viral_median_OS_Non_viral, 2), " months\n",
                               "95% CI: ", round(Viral_Not_Viral_lower_OS_ci_Non_viral, 2), "-", round(Viral_Not_Viral_upper_OS_ci_Non_viral, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 37, y = 0.90,
                 label = paste("Viral \nMedian OS: ", round(Viral_Not_Viral_median_OS_Viral, 2), " months\n",
                               "95% CI: ", round(Viral_Not_Viral_lower_OS_ci_Viral, 2), "-", round(Viral_Not_Viral_upper_OS_ci_Viral, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")
## Error: object 'Viral_Not_Viral_OS_plot' not found
# Print the plot in the R Markdown document
print(Viral_Not_Viral_OS_plot)
## Error: object 'Viral_Not_Viral_OS_plot' not found
# High-resolution plot saving
png("Viral_Not_Viral_OS_TKIs.png", width = 8, height = 6, units = "in", res = 300)
print(Viral_Not_Viral_OS_plot)
## Error: object 'Viral_Not_Viral_OS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.14 Viral vs. Non Viral aetiology as predictor for PFS

#### Viral_Not_Viral Analysis
###For Viral_Not_Viral survival curve the right hand side should be ~ Viral_Not_Viral
Viral_Not_Viral_PFS = survfit(Surv(Time_PFS, PFS_Status) ~ Viral_Not_Viral , data = ClinicData)
## Error in eval(predvars, data, env): object 'Viral_Not_Viral' not found
summary_data_Viral_Not_Viral_PFS <- summary(Viral_Not_Viral_PFS)
## Error: object 'Viral_Not_Viral_PFS' not found
# Extract median PFS and confidence intervals for each group
Viral_Not_Viral_median_PFS_Non_viral <- summary_data_Viral_Not_Viral_PFS$table["Viral_Not_Viral=Non-viral", "median"]
## Error: object 'summary_data_Viral_Not_Viral_PFS' not found
Viral_Not_Viral_lower_PFS_ci_Non_viral <- summary_data_Viral_Not_Viral_PFS$table["Viral_Not_Viral=Non-viral", "0.95LCL"]
## Error: object 'summary_data_Viral_Not_Viral_PFS' not found
Viral_Not_Viral_upper_PFS_ci_Non_viral <- summary_data_Viral_Not_Viral_PFS$table["Viral_Not_Viral=Non-viral", "0.95UCL"]
## Error: object 'summary_data_Viral_Not_Viral_PFS' not found
Viral_Not_Viral_median_PFS_Viral <- summary_data_Viral_Not_Viral_PFS$table["Viral_Not_Viral=Viral", "median"]
## Error: object 'summary_data_Viral_Not_Viral_PFS' not found
Viral_Not_Viral_lower_PFS_ci_Viral <- summary_data_Viral_Not_Viral_PFS$table["Viral_Not_Viral=Viral", "0.95LCL"]
## Error: object 'summary_data_Viral_Not_Viral_PFS' not found
Viral_Not_Viral_upper_PFS_ci_Viral <- summary_data_Viral_Not_Viral_PFS$table["Viral_Not_Viral=Viral", "0.95UCL"]
## Error: object 'summary_data_Viral_Not_Viral_PFS' not found
Viral_Not_Viral_PFS_plot <- ggsurvplot(Viral_Not_Viral_PFS,
                      conf.int=FALSE, # add confidence intervals
                      pval=TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, #corresponds to survival curves' comparison
                      pval.size= 4,# numeric value specifying the p-value text size. Default is 5.
                      test.for.trend = FALSE,
                      risk.table=TRUE,# show a risk table below the plot.
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", #for drawing a horizontal/vertical line at median survival.
                      legend.labs=c("Non viral", "Viral"), # change group labels
                      tables.col = "strata",
                      tables.y.text.col=TRUE,
                      fontsize=5,
                      legend.title="Aetiology",  # add legend title
                      risk.table.title="Number at risk", #the title to be used for the risk table.
                      title=NULL, # add title to plot
                      risk.table.height=.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab="Time, months",
                      ylab="PFS Probability",
                      axes.offset=TRUE,
                      surv.plot.height=1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title=15)
## Error: object 'Viral_Not_Viral_PFS' not found
# Annotate the median PFS and confidence interval for group
Viral_Not_Viral_PFS_plot$plot <- Viral_Not_Viral_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.60, 
                 label = paste("Non viral \nMedian PFS: ", round(Viral_Not_Viral_median_PFS_Non_viral, 2), " months\n",
                               "95% CI: ", round(Viral_Not_Viral_lower_PFS_ci_Non_viral, 2), "-", round(Viral_Not_Viral_upper_PFS_ci_Non_viral, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 25, y = 0.90,
                 label = paste("Viral \nMedian PFS: ", round(Viral_Not_Viral_median_PFS_Viral, 2), " months\n",
                               "95% CI: ", round(Viral_Not_Viral_lower_PFS_ci_Viral, 2), "-", round(Viral_Not_Viral_upper_PFS_ci_Viral, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")
## Error: object 'Viral_Not_Viral_PFS_plot' not found
# Print the plot in the R Markdown document
print(Viral_Not_Viral_PFS_plot)
## Error: object 'Viral_Not_Viral_PFS_plot' not found
# High-resolution plot saving
png("Viral_Not_Viral_PFS_TKIs.png", width = 8, height = 6, units = "in", res = 300)
print(Viral_Not_Viral_PFS_plot)
## Error: object 'Viral_Not_Viral_PFS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.15 Tumour Size as predictor for OS

# Create binary variable for Tumour Size
TumourSize_binary <- ifelse(ClinicData$Tumour.largest.size..cm. < 5, "low", "high")
ClinicData$TumourSize_binary <- TumourSize_binary

# Fit the survival model for OS
TumourSize_OS <- survfit(Surv(Time_OS, OS_Status) ~ TumourSize_binary, data = ClinicData)
summary_data_TumourSize_OS <- summary(TumourSize_OS)

# Extract median OS and confidence intervals for high group
TumourSize_median_OS_high <- summary_data_TumourSize_OS$table["TumourSize_binary=high", "median"]
TumourSize_lower_OS_ci_high <- summary_data_TumourSize_OS$table["TumourSize_binary=high", "0.95LCL"]
TumourSize_upper_OS_ci_high <- summary_data_TumourSize_OS$table["TumourSize_binary=high", "0.95UCL"]

# Extract median OS and confidence intervals for low group
TumourSize_median_OS_low <- summary_data_TumourSize_OS$table["TumourSize_binary=low", "median"]
TumourSize_lower_OS_ci_low <- summary_data_TumourSize_OS$table["TumourSize_binary=low", "0.95LCL"]
TumourSize_upper_OS_ci_low <- summary_data_TumourSize_OS$table["TumourSize_binary=low", "0.95UCL"]

# Create the survival plot
TumourSize_OS_plot <- ggsurvplot(TumourSize_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(40, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(40, 0.20),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("Tumour size ≥ 5", "Tumour size < 5 cm"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for each group
TumourSize_OS_plot$plot <- TumourSize_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.45, 
                 label = paste("Tumour size < 5 cm\nMedian OS:", round(TumourSize_median_OS_low, 2), "months\n",
                               "95% CI:", round(TumourSize_lower_OS_ci_low, 2), "-", round(TumourSize_upper_OS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.75, 
                 label = paste("Tumour size ≥ 5 cm\nMedian OS:", round(TumourSize_median_OS_high, 2), "months\n",
                               "95% CI:", round(TumourSize_lower_OS_ci_high, 2), "-", round(TumourSize_upper_OS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(TumourSize_OS_plot)

# High-resolution plot saving
png("TumourSize_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(TumourSize_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.16 Tumour Size as predictor for PFS

# Create binary variable for Tumour Size
TumourSize_binary <- ifelse(ClinicData$Tumour.largest.size..cm. < 5, "low", "high")
ClinicData$TumourSize_binary <- TumourSize_binary

# Fit the survival model for PFS
TumourSize_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ TumourSize_binary, data = ClinicData)
summary_data_TumourSize_PFS <- summary(TumourSize_PFS)

# Extract median PFS and confidence intervals for high group
TumourSize_median_PFS_high <- summary_data_TumourSize_PFS$table["TumourSize_binary=high", "median"]
TumourSize_lower_PFS_ci_high <- summary_data_TumourSize_PFS$table["TumourSize_binary=high", "0.95LCL"]
TumourSize_upper_PFS_ci_high <- summary_data_TumourSize_PFS$table["TumourSize_binary=high", "0.95UCL"]

# Extract median PFS and confidence intervals for low group
TumourSize_median_PFS_low <- summary_data_TumourSize_PFS$table["TumourSize_binary=low", "median"]
TumourSize_lower_PFS_ci_low <- summary_data_TumourSize_PFS$table["TumourSize_binary=low", "0.95LCL"]
TumourSize_upper_PFS_ci_low <- summary_data_TumourSize_PFS$table["TumourSize_binary=low", "0.95UCL"]

# Create the survival plot
TumourSize_PFS_plot <- ggsurvplot(TumourSize_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(30, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(30, 0.20),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("Tumour size ≥ 5", "Tumour size < 5 cm"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for each group
TumourSize_PFS_plot$plot <- TumourSize_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.45, 
                 label = paste("Tumour size < 5 cm\nMedian PFS:", round(TumourSize_median_PFS_low, 2), "months\n",
                               "95% CI:", round(TumourSize_lower_PFS_ci_low, 2), "-", round(TumourSize_upper_PFS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.75, 
                 label = paste("Tumour size ≥ 5 cm\nMedian PFS:", round(TumourSize_median_PFS_high, 2), "months\n",
                               "95% CI:", round(TumourSize_lower_PFS_ci_high, 2), "-", round(TumourSize_upper_PFS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(TumourSize_PFS_plot)

# High-resolution plot saving
png("TumourSize_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(TumourSize_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.17 tMAD score as predictor for OS

# Create binary variable for Tumour Size
tMAD_binary <- ifelse(ClinicData$tMAD.Score <= 0.02, "low", "high")
ClinicData$tMAD_binary <- tMAD_binary
## Error in `$<-.data.frame`(`*tmp*`, tMAD_binary, value = logical(0)): replacement has 0 rows, data has 134
# Fit the survival model for OS
tMAD_OS <- survfit(Surv(Time_OS, OS_Status) ~ tMAD_binary, data = ClinicData, conf.type = "log-log")
## Error in model.frame.default(formula = Surv(Time_OS, OS_Status) ~ tMAD_binary, : variable lengths differ (found for 'tMAD_binary')
summary_data_tMAD_OS <- summary(tMAD_OS)
## Error: object 'tMAD_OS' not found
# Extract median OS and confidence intervals for high group
tMAD_median_OS_high <- summary_data_tMAD_OS$table["tMAD_binary=high", "median"]
## Error: object 'summary_data_tMAD_OS' not found
tMAD_lower_OS_ci_high <- summary_data_tMAD_OS$table["tMAD_binary=high", "0.95LCL"]
## Error: object 'summary_data_tMAD_OS' not found
tMAD_upper_OS_ci_high <- summary_data_tMAD_OS$table["tMAD_binary=high", "0.95UCL"]
## Error: object 'summary_data_tMAD_OS' not found
# Extract median OS and confidence intervals for low group
tMAD_median_OS_low <- summary_data_tMAD_OS$table["tMAD_binary=low", "median"]
## Error: object 'summary_data_tMAD_OS' not found
tMAD_lower_OS_ci_low <- summary_data_tMAD_OS$table["tMAD_binary=low", "0.95LCL"]
## Error: object 'summary_data_tMAD_OS' not found
tMAD_upper_OS_ci_low <- summary_data_tMAD_OS$table["tMAD_binary=low", "0.95UCL"]
## Error: object 'summary_data_tMAD_OS' not found
# Create the survival plot
tMAD_OS_plot <- ggsurvplot(tMAD_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(5, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(5, 0.25),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = NULL, # horizontal/vertical line at median survival
                             legend.labs = c("tMAD > 0.02", "tMAD ≤ 0.02"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)
## Error: object 'tMAD_OS' not found
# Annotate the median OS and confidence interval for each group
tMAD_OS_plot$plot <- tMAD_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.45, 
                 label = paste("tMAD ≤ 0.02 \nMedian OS:", round(tMAD_median_OS_low, 2), "months\n",
                               "95% CI:", round(tMAD_lower_OS_ci_low, 2), "-", round(tMAD_upper_OS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.75, 
                 label = paste("tMAD > 0.02 \nMedian OS:", round(tMAD_median_OS_high, 2), "months\n",
                               "95% CI:", round(tMAD_lower_OS_ci_high, 2), "-", round(tMAD_upper_OS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")
## Error: object 'tMAD_OS_plot' not found
# Print the plot in the R Markdown document
print(tMAD_OS_plot)
## Error: object 'tMAD_OS_plot' not found
# High-resolution plot saving
png("tMAD_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(tMAD_OS_plot)
## Error: object 'tMAD_OS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.18 tMAD score as predictor for PFS

# Create binary variable for Tumour Size
tMAD_binary <- ifelse(ClinicData$tMAD.Score <= 0.02, "low", "high")
ClinicData$tMAD_binary <- tMAD_binary
## Error in `$<-.data.frame`(`*tmp*`, tMAD_binary, value = logical(0)): replacement has 0 rows, data has 134
# Fit the survival model for PFS
tMAD_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ tMAD_binary, data = ClinicData, conf.type = "log-log")
## Error in model.frame.default(formula = Surv(Time_PFS, PFS_Status) ~ tMAD_binary, : variable lengths differ (found for 'tMAD_binary')
summary_data_tMAD_PFS <- summary(tMAD_PFS)
## Error: object 'tMAD_PFS' not found
# Extract median PFS and confidence intervals for high group
tMAD_median_PFS_high <- summary_data_tMAD_PFS$table["tMAD_binary=high", "median"]
## Error: object 'summary_data_tMAD_PFS' not found
tMAD_lower_PFS_ci_high <- summary_data_tMAD_PFS$table["tMAD_binary=high", "0.95LCL"]
## Error: object 'summary_data_tMAD_PFS' not found
tMAD_upper_PFS_ci_high <- summary_data_tMAD_PFS$table["tMAD_binary=high", "0.95UCL"]
## Error: object 'summary_data_tMAD_PFS' not found
# Extract median PFS and confidence intervals for low group
tMAD_median_PFS_low <- summary_data_tMAD_PFS$table["tMAD_binary=low", "median"]
## Error: object 'summary_data_tMAD_PFS' not found
tMAD_lower_PFS_ci_low <- summary_data_tMAD_PFS$table["tMAD_binary=low", "0.95LCL"]
## Error: object 'summary_data_tMAD_PFS' not found
tMAD_upper_PFS_ci_low <- summary_data_tMAD_PFS$table["tMAD_binary=low", "0.95UCL"]
## Error: object 'summary_data_tMAD_PFS' not found
# Create the survival plot
tMAD_PFS_plot <- ggsurvplot(tMAD_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(30, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(30, 0.20),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = NULL, # horizontal/vertical line at median survival
                             legend.labs = c("tMAD > 0.02", "tMAD ≤ 0.02"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)
## Error: object 'tMAD_PFS' not found
# Annotate the median PFS and confidence interval for each group
tMAD_PFS_plot$plot <- tMAD_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.45, 
                 label = paste("tMAD ≤ 0.02 \nMedian PFS:", round(tMAD_median_PFS_low, 2), "months\n",
                               "95% CI:", round(tMAD_lower_PFS_ci_low, 2), "-", round(tMAD_upper_PFS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.75, 
                 label = paste("tMAD > 0.02 \nMedian PFS:", round(tMAD_median_PFS_high, 2), "months\n",
                               "95% CI:", round(tMAD_lower_PFS_ci_high, 2), "-", round(tMAD_upper_PFS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")
## Error: object 'tMAD_PFS_plot' not found
# Print the plot in the R Markdown document
print(tMAD_PFS_plot)
## Error: object 'tMAD_PFS_plot' not found
# High-resolution plot saving
png("tMAD_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(tMAD_PFS_plot)
## Error: object 'tMAD_PFS_plot' not found
dev.off()
## quartz_off_screen 
##                 2

1.19 DELFI score as predictor for OS

# Create binary variable for Tumour Size
ClinicData <- read.csv("/Volumes/Samsung_SSD_8TB/Chapter 2 (Prognostic Indicators for HCC)/ICI_TKI_Ram_Sul_Mat_2025-01-29_Final.csv")
DELFI_binary <- ifelse(ClinicData$DELFI_Baseline <= 0.287, "low", "high")
ClinicData$DELFI_Baseline <- DELFI_binary

# Fit the survival model for OS
DELFI_OS <- survfit(Surv(Time_OS, OS_Status) ~ DELFI_binary, data = ClinicData, conf.type = "log-log")
summary_data_DELFI_OS <- summary(DELFI_OS)

# Extract median OS and confidence intervals for high group
DELFI_median_OS_high <- summary_data_DELFI_OS$table["DELFI_binary=high", "median"]
DELFI_lower_OS_ci_high <- summary_data_DELFI_OS$table["DELFI_binary=high", "0.95LCL"]
DELFI_upper_OS_ci_high <- summary_data_DELFI_OS$table["DELFI_binary=high", "0.95UCL"]

# Extract median OS and confidence intervals for low group
DELFI_median_OS_low <- summary_data_DELFI_OS$table["DELFI_binary=low", "median"]
DELFI_lower_OS_ci_low <- summary_data_DELFI_OS$table["DELFI_binary=low", "0.95LCL"]
DELFI_upper_OS_ci_low <- summary_data_DELFI_OS$table["DELFI_binary=low", "0.95UCL"]

# Create the survival plot
DELFI_OS_plot <- ggsurvplot(DELFI_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(40, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(40, 0.25),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("DELFI > 0.4", "DELFI ≤ 0.4"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for each group
DELFI_OS_plot$plot <- DELFI_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.45, 
                 label = paste("DELFI ≤ 0.3 \nMedian OS:", round(DELFI_median_OS_low, 2), "months\n",
                               "95% CI:", round(DELFI_lower_OS_ci_low, 2), "-", round(DELFI_upper_OS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.75, 
                 label = paste("DELFI > 0.3 \nMedian OS:", round(DELFI_median_OS_high, 2), "months\n",
                               "95% CI:", round(DELFI_lower_OS_ci_high, 2), "-", round(DELFI_upper_OS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(DELFI_OS_plot)

# High-resolution plot saving
png("DELFI_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(DELFI_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.20 DELFI score as predictor for PFS

# Create binary variable for Tumour Size
ClinicData <- read.csv("/Volumes/Samsung_SSD_8TB/Chapter 2 (Prognostic Indicators for HCC)/ICI_TKI_Ram_Sul_Mat_2025-01-29_Final.csv")
DELFI_binary <- ifelse(ClinicData$DELFI_Baseline <= 0.287, "low", "high")
ClinicData$DELFI_Baseline <- DELFI_binary

# Fit the survival model for PFS
DELFI_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ DELFI_binary, data = ClinicData, conf.type = "log-log")
summary_data_DELFI_PFS <- summary(DELFI_PFS)

# Extract median PFS and confidence intervals for high group
DELFI_median_PFS_high <- summary_data_DELFI_PFS$table["DELFI_binary=high", "median"]
DELFI_lower_PFS_ci_high <- summary_data_DELFI_PFS$table["DELFI_binary=high", "0.95LCL"]
DELFI_upper_PFS_ci_high <- summary_data_DELFI_PFS$table["DELFI_binary=high", "0.95UCL"]

# Extract median PFS and confidence intervals for low group
DELFI_median_PFS_low <- summary_data_DELFI_PFS$table["DELFI_binary=low", "median"]
DELFI_lower_PFS_ci_low <- summary_data_DELFI_PFS$table["DELFI_binary=low", "0.95LCL"]
DELFI_upper_PFS_ci_low <- summary_data_DELFI_PFS$table["DELFI_binary=low", "0.95UCL"]

# Create the survival plot
DELFI_PFS_plot <- ggsurvplot(DELFI_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(30, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(30, 0.20),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("High DELFI", "Low DELFI"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for each group
DELFI_PFS_plot$plot <- DELFI_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.45, 
                 label = paste("Low DELFI \nMedian PFS:", round(DELFI_median_PFS_low, 2), "months\n",
                               "95% CI:", round(DELFI_lower_PFS_ci_low, 2), "-", round(DELFI_upper_PFS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.75, 
                 label = paste("High DELFI \nMedian PFS:", round(DELFI_median_PFS_high, 2), "months\n",
                               "95% CI:", round(DELFI_lower_PFS_ci_high, 2), "-", round(DELFI_upper_PFS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(DELFI_PFS_plot)

# High-resolution plot saving
png("DELFI_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(DELFI_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.21 Response as predictor for OS

# Fit the survival model for OS
Responsce_OS = survfit(Surv(Time_OS, OS_Status) ~Best_Responsce , data = ClinicData, conf.type = "log-log")
summary_data_Responsce_OS <- summary(Responsce_OS)

# Extract median OS and confidence intervals for high group
Responsce_median_OS_PD <- summary_data_Responsce_OS$table["Best_Responsce=PD", "median"]
Responsce_lower_OS_ci_PD <- summary_data_Responsce_OS$table["Best_Responsce=PD", "0.95LCL"]
Responsce_upper_OS_ci_PD <- summary_data_Responsce_OS$table["Best_Responsce=PD", "0.95UCL"]

# Extract median OS and confidence intervals for low group
Responsce_median_OS_SD <- summary_data_Responsce_OS$table["Best_Responsce=SD", "median"]
Responsce_lower_OS_ci_SD <- summary_data_Responsce_OS$table["Best_Responsce=SD", "0.95LCL"]
Responsce_upper_OS_ci_SD <- summary_data_Responsce_OS$table["Best_Responsce=SD", "0.95UCL"]

# Create the survival plot
Responsce_OS_plot <- ggsurvplot(Responsce_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(45, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(45, 0.18),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("PD", "SD"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "Responsce",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for each group
Responsce_OS_plot$plot <- Responsce_OS_plot$plot + 
  geom_label(aes(x = 40, y = 0.45, 
                 label = paste("PD\nMedian OS:", round(Responsce_median_OS_PD, 2), "months\n",
                               "95% CI:", round(Responsce_lower_OS_ci_PD, 2), "-", round(Responsce_upper_OS_ci_PD, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 40, y = 0.75,
                 label = paste("SD\nMedian OS:", round(Responsce_median_OS_SD, 2), "months\n",
                               "95% CI:", round(Responsce_lower_OS_ci_SD, 2), "-", round(Responsce_upper_OS_ci_SD, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")

# Print the plot in the R Markdown document
print(Responsce_OS_plot)

# High-resolution plot saving
png("Responsce_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(Responsce_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.22 Response Size as predictor for PFS

# Fit the survival model for PFS
Responsce_PFS = survfit(Surv(Time_PFS, PFS_Status) ~Best_Responsce , data = ClinicData, conf.type = "log-log")
summary_data_Responsce_PFS <- summary(Responsce_PFS)

# Extract median PFS and confidence intervals for high group
Responsce_median_PFS_PD <- summary_data_Responsce_PFS$table["Best_Responsce=PD", "median"]
Responsce_lower_PFS_ci_PD <- summary_data_Responsce_PFS$table["Best_Responsce=PD", "0.95LCL"]
Responsce_upper_PFS_ci_PD <- summary_data_Responsce_PFS$table["Best_Responsce=PD", "0.95UCL"]

# Extract median PFS and confidence intervals for low group
Responsce_median_PFS_SD <- summary_data_Responsce_PFS$table["Best_Responsce=SD", "median"]
Responsce_lower_PFS_ci_SD <- summary_data_Responsce_PFS$table["Best_Responsce=SD", "0.95LCL"]
Responsce_upper_PFS_ci_SD <- summary_data_Responsce_PFS$table["Best_Responsce=SD", "0.95UCL"]

# Create the survival plot
Responsce_PFS_plot <- ggsurvplot(Responsce_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(30, 0.20), # <- move the "log-rank" method label here
                             pval.coord = c(30, 0.15),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("PD", "SD"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "Responsce",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for each group
Responsce_PFS_plot$plot <- Responsce_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.45, 
                 label = paste("PD\nMedian PFS:", round(Responsce_median_PFS_PD, 2), "months\n",
                               "95% CI:", round(Responsce_lower_PFS_ci_PD, 2), "-", round(Responsce_upper_PFS_ci_PD, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 25, y = 0.75,
                 label = paste("SD\nMedian PFS:", round(Responsce_median_PFS_SD, 2), "months\n",
                               "95% CI:", round(Responsce_lower_PFS_ci_SD, 2), "-", round(Responsce_upper_PFS_ci_SD, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")

# Print the plot in the R Markdown document
print(Responsce_PFS_plot)

# High-resolution plot saving
png("Responsce_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(Responsce_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.23 AFP as predictor for OS

# Create binary variable for AFP
AFP_binary <- ifelse(ClinicData$AFP <= 400, "low", "high")
ClinicData$AFP_binary <- AFP_binary

# Fit the survival model for OS
AFP_OS <- survfit(Surv(Time_OS, OS_Status) ~ AFP_binary, data = ClinicData, conf.type = "log-log")
summary_data_AFP_OS <- summary(AFP_OS)

# Extract median OS and confidence intervals for high group
AFP_median_OS_high <- summary_data_AFP_OS$table["AFP_binary=high", "median"]
AFP_lower_OS_ci_high <- summary_data_AFP_OS$table["AFP_binary=high", "0.95LCL"]
AFP_upper_OS_ci_high <- summary_data_AFP_OS$table["AFP_binary=high", "0.95UCL"]

# Extract median OS and confidence intervals for low group
AFP_median_OS_low <- summary_data_AFP_OS$table["AFP_binary=low", "median"]
AFP_lower_OS_ci_low <- summary_data_AFP_OS$table["AFP_binary=low", "0.95LCL"]
AFP_upper_OS_ci_low <- summary_data_AFP_OS$table["AFP_binary=low", "0.95UCL"]

# Create the survival plot
AFP_OS_plot <- ggsurvplot(AFP_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(50, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(50, 0.18),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("AFP ≥ 400", "AFP < 400"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for each group
AFP_OS_plot$plot <- AFP_OS_plot$plot + 
  geom_label(aes(x = 40, y = 0.55, 
                 label = paste("AFP < 400\nMedian OS:", round(AFP_median_OS_low, 2), "months\n",
                               "95% CI:", round(AFP_lower_OS_ci_low, 2), "-", round(AFP_upper_OS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 40, y = 0.85, 
                 label = paste("AFP ≥ 400\nMedian OS:", round(AFP_median_OS_high, 2), "months\n",
                               "95% CI:", round(AFP_lower_OS_ci_high, 2), "-", round(AFP_upper_OS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(AFP_OS_plot)

# High-resolution plot saving
png("AFP_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(AFP_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.24 AFP as predictor for PFS

# Create binary variable for AFP
AFP_binary <- ifelse(ClinicData$AFP <= 400, "low", "high")
ClinicData$AFP_binary <- AFP_binary

# Fit the survival model for PFS
AFP_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ AFP_binary, data = ClinicData, conf.type = "log-log")
summary_data_AFP_PFS <- summary(AFP_PFS)

# Extract median PFS and confidence intervals for high group
AFP_median_PFS_high <- summary_data_AFP_PFS$table["AFP_binary=high", "median"]
AFP_lower_PFS_ci_high <- summary_data_AFP_PFS$table["AFP_binary=high", "0.95LCL"]
AFP_upper_PFS_ci_high <- summary_data_AFP_PFS$table["AFP_binary=high", "0.95UCL"]

# Extract median PFS and confidence intervals for low group
AFP_median_PFS_low <- summary_data_AFP_PFS$table["AFP_binary=low", "median"]
AFP_lower_PFS_ci_low <- summary_data_AFP_PFS$table["AFP_binary=low", "0.95LCL"]
AFP_upper_PFS_ci_low <- summary_data_AFP_PFS$table["AFP_binary=low", "0.95UCL"]

# Create the survival plot
AFP_PFS_plot <- ggsurvplot(AFP_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(35, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(35, 0.18),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("AFP ≥ 400", "AFP < 400"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for each group
AFP_PFS_plot$plot <- AFP_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.45, 
                 label = paste("AFP < 400\nMedian PFS:", round(AFP_median_PFS_low, 2), "months\n",
                               "95% CI:", round(AFP_lower_PFS_ci_low, 2), "-", round(AFP_upper_PFS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.75, 
                 label = paste("AFP ≥ 400\nMedian PFS:", round(AFP_median_PFS_high, 2), "months\n",
                               "95% CI:", round(AFP_lower_PFS_ci_high, 2), "-", round(AFP_upper_PFS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(AFP_PFS_plot)

# High-resolution plot saving
png("AFP_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(AFP_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.25 Age as predictor for OS

# Create binary variable for Age
Age_binary <- ifelse(ClinicData$Age <= 70, "low", "high")
ClinicData$Age_binary <- Age_binary

# Fit the survival model for OS
Age_OS <- survfit(Surv(Time_OS, OS_Status) ~ Age_binary, data = ClinicData, conf.type = "log-log")
summary_data_Age_OS <- summary(Age_OS)

# Extract median OS and confidence intervals for high group
Age_median_OS_high <- summary_data_Age_OS$table["Age_binary=high", "median"]
Age_lower_OS_ci_high <- summary_data_Age_OS$table["Age_binary=high", "0.95LCL"]
Age_upper_OS_ci_high <- summary_data_Age_OS$table["Age_binary=high", "0.95UCL"]

# Extract median OS and confidence intervals for low group
Age_median_OS_low <- summary_data_Age_OS$table["Age_binary=low", "median"]
Age_lower_OS_ci_low <- summary_data_Age_OS$table["Age_binary=low", "0.95LCL"]
Age_upper_OS_ci_low <- summary_data_Age_OS$table["Age_binary=low", "0.95UCL"]

# Create the survival plot
Age_OS_plot <- ggsurvplot(Age_OS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(45, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(45, 0.20),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("Age > 70", "Age ≤ 70"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for each group
Age_OS_plot$plot <- Age_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.45, 
                 label = paste("Age ≤ 70 \nMedian OS:", round(Age_median_OS_low, 2), "months\n",
                               "95% CI:", round(Age_lower_OS_ci_low, 2), "-", round(Age_upper_OS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.75, 
                 label = paste("Age > 70 \nMedian OS:", round(Age_median_OS_high, 2), "months\n",
                               "95% CI:", round(Age_lower_OS_ci_high, 2), "-", round(Age_upper_OS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(Age_OS_plot)

# High-resolution plot saving
png("Age_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(Age_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.26 Age as predictor for PFS

# Create binary variable for Age
Age_binary <- ifelse(ClinicData$Age <= 70, "low", "high")
ClinicData$Age_binary <- Age_binary

# Fit the survival model for PFS
Age_PFS <- survfit(Surv(Time_PFS, PFS_Status) ~ Age_binary, data = ClinicData, conf.type = "log-log")
summary_data_Age_PFS <- summary(Age_PFS)

# Extract median PFS and confidence intervals for high group
Age_median_PFS_high <- summary_data_Age_PFS$table["Age_binary=high", "median"]
Age_lower_PFS_ci_high <- summary_data_Age_PFS$table["Age_binary=high", "0.95LCL"]
Age_upper_PFS_ci_high <- summary_data_Age_PFS$table["Age_binary=high", "0.95UCL"]

# Extract median PFS and confidence intervals for low group
Age_median_PFS_low <- summary_data_Age_PFS$table["Age_binary=low", "median"]
Age_lower_PFS_ci_low <- summary_data_Age_PFS$table["Age_binary=low", "0.95LCL"]
Age_upper_PFS_ci_low <- summary_data_Age_PFS$table["Age_binary=low", "0.95UCL"]

# Create the survival plot
Age_PFS_plot <- ggsurvplot(Age_PFS,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(35, 0.20), # <- move the "log-rank" method label here
                             pval.coord = c(35, 0.15),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("Age > 70", "Age ≤ 70"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median PFS and confidence interval for each group
Age_PFS_plot$plot <- Age_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.45, 
                 label = paste("Age ≤ 70 \nMedian PFS:", round(Age_median_PFS_low, 2), "months\n",
                               "95% CI:", round(Age_lower_PFS_ci_low, 2), "-", round(Age_upper_PFS_ci_low, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.75, 
                 label = paste("Age > 70 \nMedian PFS:", round(Age_median_PFS_high, 2), "months\n",
                               "95% CI:", round(Age_lower_PFS_ci_high, 2), "-", round(Age_upper_PFS_ci_high, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(Age_PFS_plot)

# High-resolution plot saving
png("Age_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(Age_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.27 Treatment as predictor for OS

# Ensure consistent strata order
ClinicData$Treatment.Class <- factor(ClinicData$Treatment.Class,
                                     levels = c("TKI","ICI"))
## Error in `$<-.data.frame`(`*tmp*`, Treatment.Class, value = structure(integer(0), levels = c("TKI", : replacement has 0 rows, data has 134
# Fit
fit <- survfit(Surv(Time_OS, OS_Status) ~ Treatment.Class,
               data = ClinicData, conf.type = "log-log")
## Error in eval(predvars, data, env): object 'Treatment.Class' not found
# Medians
med <- survminer::surv_median(fit)
## Error: object 'fit' not found
med$group <- sub(".*=", "", med$strata)
## Error: object 'med' not found
tki <- med[med$group=="TKI",]; ici <- med[med$group=="ICI",]
## Error: object 'med' not found
# Named palette (GGplot defaults shown; change if you prefer)
pal <- c(TKI = "#F8766D", ICI = "#00BFC4")

plt <- ggsurvplot(
  fit,
  palette = pal,                 # <- named mapping
  legend.labs = c("TKI","ICI"),
  legend.title = "Treatment",
  conf.int = FALSE,
  pval = TRUE, pval.method = TRUE,
  pval.method.coord = c(40, 0.30), # <- move the "log-rank" method label here
  pval.coord = c(40, 0.20),       # <- move the log-rank p-value here (x, y)
  risk.table = TRUE, tables.col = "strata", tables.y.text.col = TRUE,
  surv.median.line = "hv",
  xlab = "Time, months", ylab = "OS Probability",
  risk.table.height = 0.25, surv.plot.height = 1,
  font.x = 15, font.y = 15, font.legend.title = 15, fontsize = 5
)
## Error: object 'fit' not found
# Use the same palette for annotation fills
plt$plot <- plt$plot +
  annotate("label", x = 37, y = 0.60,
           label = sprintf("TKI\nMedian OS: %.2f months\n95%% CI: %.2f–%.2f",
                           tki$median, tki$lower, tki$upper),
           size = 4, hjust = 0, vjust = 1, color = "black",
           fill = pal["TKI"]) +
  annotate("label", x = 37, y = 0.90,
           label = sprintf("ICI\nMedian OS: %.2f months\n95%% CI: %.2f–%.2f",
                           ici$median, ici$lower, ici$upper),
           size = 4, hjust = 0, vjust = 1, color = "black",
           fill = pal["ICI"])
## Error: object 'plt' not found
# Save high-resolution Kaplan–Meier OS plot
png("Treatment_Type_OS_TKI_ICI.png", 
    width = 8, height = 6, units = "in", res = 500)   # You can use 300 or 600 dpi
print(plt)
## Error: object 'plt' not found
dev.off()
## quartz_off_screen 
##                 2

1.28 Treatment as predictor for PFS

# Ensure consistent strata order
ClinicData$Treatment.Class <- factor(ClinicData$Treatment.Class,
                                     levels = c("TKI","ICI"))
## Error in `$<-.data.frame`(`*tmp*`, Treatment.Class, value = structure(integer(0), levels = c("TKI", : replacement has 0 rows, data has 134
# Fit
fit <- survfit(Surv(Time_PFS, PFS_Status) ~ Treatment.Class,
               data = ClinicData, conf.type = "log-log")
## Error in eval(predvars, data, env): object 'Treatment.Class' not found
# Medians
med <- survminer::surv_median(fit)
## Error: object 'fit' not found
med$group <- sub(".*=", "", med$strata)
## Error: object 'med' not found
tki <- med[med$group=="TKI",]; ici <- med[med$group=="ICI",]
## Error: object 'med' not found
# Named palette (GGplot defaults shown; change if you prefer)
pal <- c(TKI = "#F8766D", ICI = "#00BFC4")

plt <- ggsurvplot(
  fit,
  palette = pal,                 # <- named mapping
  legend.labs = c("TKI","ICI"),
  legend.title = "Treatment",
  conf.int = FALSE,
  pval = TRUE, pval.method = TRUE,
  pval.method.coord = c(40, 0.30), # <- move the "log-rank" method label here
  pval.coord = c(40, 0.20),       # <- move the log-rank p-value here (x, y)
  risk.table = TRUE, tables.col = "strata", tables.y.text.col = TRUE,
  surv.median.line = "hv",
  xlab = "Time, months", ylab = "PFS Probability",
  risk.table.height = 0.25, surv.plot.height = 1,
  font.x = 15, font.y = 15, font.legend.title = 15, fontsize = 5
)
## Error: object 'fit' not found
# Use the same palette for annotation fills
plt$plot <- plt$plot +
  annotate("label", x = 37, y = 0.60,
           label = sprintf("TKI\nMedian PFS: %.2f months\n95%% CI: %.2f–%.2f",
                           tki$median, tki$lower, tki$upper),
           size = 4, hjust = 0, vjust = 1, color = "black",
           fill = pal["TKI"]) +
  annotate("label", x = 37, y = 0.90,
           label = sprintf("ICI\nMedian PFS: %.2f months\n95%% CI: %.2f–%.2f",
                           ici$median, ici$lower, ici$upper),
           size = 4, hjust = 0, vjust = 1, color = "black",
           fill = pal["ICI"])
## Error: object 'plt' not found
# Save high-resolution Kaplan–Meier OS plot
png("Treatment_Type_PFS_TKI_ICI.png", 
    width = 8, height = 6, units = "in", res = 500)   # You can use 300 or 600 dpi
print(plt)
## Error: object 'plt' not found
dev.off()
## quartz_off_screen 
##                 2

1.29 PVT_EHS as predictor for OS

#### PVT_EHS Analysis
###For PVT_EHS survival curve the right hand side should be ~ PVT_EHS
PVT_EHS_OS = survfit(Surv(Time_OS, OS_Status) ~ PVT , data = ClinicData)
summary_data_PVT_EHS_OS <- summary(PVT_EHS_OS)
# Extract median OS and confidence intervals for each group
PVT_EHS_median_OS_NO <- summary_data_PVT_EHS_OS$table["PVT=No", "median"]
PVT_EHS_lower_OS_ci_NO <- summary_data_PVT_EHS_OS$table["PVT=No", "0.95LCL"]
PVT_EHS_upper_OS_ci_NO <- summary_data_PVT_EHS_OS$table["PVT=No", "0.95UCL"]

PVT_EHS_median_OS_YES <- summary_data_PVT_EHS_OS$table["PVT=Yes", "median"]
PVT_EHS_lower_OS_ci_YES <- summary_data_PVT_EHS_OS$table["PVT=Yes", "0.95LCL"]
PVT_EHS_upper_OS_ci_YES <- summary_data_PVT_EHS_OS$table["PVT=Yes", "0.95UCL"]


PVT_EHS_OS_plot <- ggsurvplot(PVT_EHS_OS,
                      conf.int=FALSE, # add confidence intervals
                      pval=TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, #corresponds to survival curves' comparison
                      pval.size= 4,# numeric value specifying the p-value text size. Default is 5.
                      pval.method.coord = c(45, 0.30), # <- move the "log-rank" method label here
                      pval.coord = c(45, 0.25),  
                      test.for.trend = FALSE,
                      risk.table=TRUE,# show a risk table below the plot.
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", #for drawing a horizontal/vertical line at median survival.
                      legend.labs=c("Absent", "Present"), # change group labels
                      tables.col = "strata",
                      tables.y.text.col=TRUE,
                      fontsize=5,
                      legend.title="PVT",  # add legend title
                      risk.table.title="Number at risk", #the title to be used for the risk table.
                      title=NULL, # add title to plot
                      risk.table.height=.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab="Time, months",
                      ylab="OS Probability",
                      axes.offset=TRUE,
                      surv.plot.height=1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title=15)
# Annotate the median OS and confidence interval for group
PVT_EHS_OS_plot$plot <- PVT_EHS_OS_plot$plot + 
  geom_label(aes(x = 37, y = 0.60, 
                 label = paste("Absent \nMedian OS: ", round(PVT_EHS_median_OS_NO, 2), " months\n",
                               "95% CI: ", round(PVT_EHS_lower_OS_ci_NO, 2), "-", round(PVT_EHS_upper_OS_ci_NO, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 37, y = 0.90,
                 label = paste("Present \nMedian OS: ", round(PVT_EHS_median_OS_YES, 2), " months\n",
                               "95% CI: ", round(PVT_EHS_lower_OS_ci_YES, 2), "-", round(PVT_EHS_upper_OS_ci_YES, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")

# Print the plot in the R Markdown document
print(PVT_EHS_OS_plot)

# High-resolution plot saving
png("PVT_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(PVT_EHS_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.30 PVT_EHS as predictor for PFS

#### PVT_EHS Analysis
###For PVT_EHS survival curve the right hand side should be ~ PVT_EHS
PVT_EHS_PFS = survfit(Surv(Time_PFS, PFS_Status) ~ PVT , data = ClinicData)
summary_data_PVT_EHS_PFS <- summary(PVT_EHS_PFS)
# Extract median PFS and confidence intervals for each group
PVT_EHS_median_PFS_NO <- summary_data_PVT_EHS_PFS$table["PVT=No", "median"]
PVT_EHS_lower_PFS_ci_NO <- summary_data_PVT_EHS_PFS$table["PVT=No", "0.95LCL"]
PVT_EHS_upper_PFS_ci_NO <- summary_data_PVT_EHS_PFS$table["PVT=No", "0.95UCL"]

PVT_EHS_median_PFS_YES <- summary_data_PVT_EHS_PFS$table["PVT=Yes", "median"]
PVT_EHS_lower_PFS_ci_YES <- summary_data_PVT_EHS_PFS$table["PVT=Yes", "0.95LCL"]
PVT_EHS_upper_PFS_ci_YES <- summary_data_PVT_EHS_PFS$table["PVT=Yes", "0.95UCL"]


PVT_EHS_PFS_plot <- ggsurvplot(PVT_EHS_PFS,
                      conf.int=FALSE, # add confidence intervals
                      pval=TRUE, # show the p-value for the log-rank test
                      pval.method = TRUE, #corresponds to survival curves' comparison
                      pval.size= 4,# numeric value specifying the p-value text size. Default is 5.
                      pval.method.coord = c(30, 0.30), # <- move the "log-rank" method label here
                      pval.coord = c(30, 0.25), 
                      test.for.trend = FALSE,
                      risk.table=TRUE,# show a risk table below the plot.
                      cumevents = FALSE,
                      cumcensor = FALSE,
                      surv.median.line = "hv", #for drawing a horizontal/vertical line at median survival.
                      legend.labs=c("Absent", "Present"), # change group labels
                      tables.col = "strata",
                      tables.y.text.col=TRUE,
                      fontsize=5,
                      legend.title="PVT",  # add legend title
                      risk.table.title="Number at risk", #the title to be used for the risk table.
                      title=NULL, # add title to plot
                      risk.table.height=.25,
                      add.all = FALSE,
                      combine = FALSE,
                      xlab="Time, months",
                      ylab="PFS Probability",
                      axes.offset=TRUE,
                      surv.plot.height=1,
                      font.x = 15,
                      font.y = 15,
                      font.legend.title=15)
# Annotate the median PFS and confidence interval for group
PVT_EHS_PFS_plot$plot <- PVT_EHS_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.60, 
                 label = paste("Absent \nMedian PFS: ", round(PVT_EHS_median_PFS_NO, 2), " months\n",
                               "95% CI: ", round(PVT_EHS_lower_PFS_ci_NO, 2), "-", round(PVT_EHS_upper_PFS_ci_NO, 2))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D") +
  geom_label(aes(x = 25, y = 0.90,
                 label = paste("Present \nMedian PFS: ", round(PVT_EHS_median_PFS_YES, 2), " months\n",
                               "95% CI: ", round(PVT_EHS_lower_PFS_ci_YES, 2), "-", round(PVT_EHS_upper_PFS_ci_YES, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4")

# Print the plot in the R Markdown document
print(PVT_EHS_PFS_plot)

# High-resolution plot saving
png("PVT_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(PVT_EHS_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.31 cfDNA levels as predictor for OS

# Create binary variable for cfDNA levels
cfDNA_Level_Baseline_binary <- ifelse(ClinicData$cfDNA_Level_Baseline_ng_ml <= 1200, "low", "high")
ClinicData$cfDNA_Level_Baseline_binary <- cfDNA_Level_Baseline_binary

# Fit the survival model for OS
cfDNA_Level_OS_fit <- survfit(Surv(Time_OS, OS_Status) ~ cfDNA_Level_Baseline_binary, data = ClinicData, conf.type = "log-log")
summary_data_cfDNA_Level_OS <- summary(cfDNA_Level_OS_fit)

# Extract median OS and confidence intervals for each group
cfDNA_Level_median_OS_low <- summary_data_cfDNA_Level_OS$time[summary_data_cfDNA_Level_OS$strata == "cfDNA_Level_Baseline_binary=low" & summary_data_cfDNA_Level_OS$time == summary_data_cfDNA_Level_OS$table["cfDNA_Level_Baseline_binary=low", "median"]]
cfDNA_Level_lower_OS_ci_low <- summary_data_cfDNA_Level_OS$table["cfDNA_Level_Baseline_binary=low", "0.95LCL"]
cfDNA_Level_upper_OS_ci_low <- summary_data_cfDNA_Level_OS$table["cfDNA_Level_Baseline_binary=low", "0.95UCL"]

cfDNA_Level_median_OS_high <- summary_data_cfDNA_Level_OS$time[summary_data_cfDNA_Level_OS$strata == "cfDNA_Level_Baseline_binary=high" & summary_data_cfDNA_Level_OS$time == summary_data_cfDNA_Level_OS$table["cfDNA_Level_Baseline_binary=high", "median"]]
cfDNA_Level_lower_OS_ci_high <- summary_data_cfDNA_Level_OS$table["cfDNA_Level_Baseline_binary=high", "0.95LCL"]
cfDNA_Level_upper_OS_ci_high <- summary_data_cfDNA_Level_OS$table["cfDNA_Level_Baseline_binary=high", "0.95UCL"]

# Create the survival plot
cfDNA_Level_OS_plot <- ggsurvplot(cfDNA_Level_OS_fit,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(45, 0.25), # <- move the "log-rank" method label here
                             pval.coord = c(45, 0.18),  
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("≥ 1200", "< 1200"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "cfDNA level (ng/ml)",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)

# Annotate the median OS and confidence interval for low group
cfDNA_Level_OS_plot$plot <- cfDNA_Level_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.45, 
                 label = paste("Low cfDNA level\nMedian OS: ", round(cfDNA_Level_median_OS_low, 1), " months\n",
                               "95% CI: ", round(cfDNA_Level_lower_OS_ci_low, 1), "-", round(cfDNA_Level_upper_OS_ci_low, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.75, 
                 label = paste("High cfDNA level\nMedian OS: ", round(cfDNA_Level_median_OS_high, 1), " months\n",
                               "95% CI: ", round(cfDNA_Level_lower_OS_ci_high, 1), "-", round(cfDNA_Level_upper_OS_ci_high, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(cfDNA_Level_OS_plot)

# High-resolution plot saving
png("cfDNA_Level_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(cfDNA_Level_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.32 cfDNA levels as predictor for PFS

library(survival)
library(survminer)

# 1) Binary with desired order/labels
ClinicData$cfDNA_bin <- factor(
  ifelse(ClinicData$cfDNA_Level_Baseline_ng_ml >= 1200, "≥ 1200", "< 1200"),
  levels = c("≥ 1200","< 1200")
)

# 2) Fit
fit <- survfit(Surv(Time_PFS, PFS_Status) ~ cfDNA_bin, data = ClinicData, conf.type = "log-log")

# 3) Medians & CIs (robust)
med <- surv_median(fit)  # from survminer
# rows are in the same order as factor levels above
med_hi  <- med$median[med$strata=="cfDNA_bin=≥ 1200"]
ciL_hi  <- med$lower[med$strata=="cfDNA_bin=≥ 1200"]
ciU_hi  <- med$upper[med$strata=="cfDNA_bin=≥ 1200"]

med_lo  <- med$median[med$strata=="cfDNA_bin=< 1200"]
ciL_lo  <- med$lower[med$strata=="cfDNA_bin=< 1200"]
ciU_lo  <- med$upper[med$strata=="cfDNA_bin=< 1200"]

# helper for pretty NA (median not reached)
fmt <- function(x) ifelse(is.na(x), "NA", sprintf("%.1f", x))

# 4) Plot (place log-rank text as you like)
p <- ggsurvplot(
  fit,
  pval = TRUE, pval.method = TRUE,
  pval.method.coord = c(30, 0.25),
  pval.coord        = c(30, 0.18),
  surv.median.line = "hv",
  risk.table = TRUE,
  legend.title = "cfDNA level (ng/ml)",
  legend.labs  = levels(ClinicData$cfDNA_bin),
  xlab = "Time, months", ylab = "PFS Probability",
  tables.col = "strata", tables.y.text.col = TRUE
)

# 5) Annotations (will show even if median is NA)
p$plot <- p$plot +
  geom_label(aes(x=25, y=0.75,
    label=paste0("High cfDNA level\nMedian PFS: ", fmt(med_hi), " months\n",
                 "95% CI: ", fmt(ciL_hi), " - ", fmt(ciU_hi))),
    size=4, hjust=0, vjust=1, color="black", fill="#F8766D") +
  geom_label(aes(x=25, y=0.45,
    label=paste0("Low cfDNA level\nMedian PFS: ", fmt(med_lo), " months\n",
                 "95% CI: ", fmt(ciL_lo), " - ", fmt(ciU_lo))),
    size=4, hjust=0, vjust=1, color="black", fill="#00BFC4")

print(p)

png("cfDNA_Level_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(p)
dev.off()
## quartz_off_screen 
##                 2

1.33 Tumour Fraction as predictor for OS

# Create binary variable for cfDNA Tumour Fraction (TF)
cfDNA_TF_Baseline_binary <- ifelse(ClinicData$Tumour_Fraction_ichorCNA_Baseline <= 0.10, "low", "high")
ClinicData$cfDNA_TF_Baseline_binary <- cfDNA_TF_Baseline_binary

# Fit the survival model for OS
cfDNA_TF_OS_fit <- survfit(Surv(Time_OS, OS_Status) ~ cfDNA_TF_Baseline_binary, data = ClinicData, conf.type = "log-log")
cfDNA_TF_summary_data_OS <- summary(cfDNA_TF_OS_fit)

# Extract median OS and confidence intervals for each group
cfDNA_TF_median_OS_low <- cfDNA_TF_summary_data_OS$table["cfDNA_TF_Baseline_binary=low", "median"]
cfDNA_TF_lower_OS_ci_low <- cfDNA_TF_summary_data_OS$table["cfDNA_TF_Baseline_binary=low", "0.95LCL"]
cfDNA_TF_upper_OS_ci_low <- cfDNA_TF_summary_data_OS$table["cfDNA_TF_Baseline_binary=low", "0.95UCL"]

cfDNA_TF_median_OS_high <- cfDNA_TF_summary_data_OS$table["cfDNA_TF_Baseline_binary=high", "median"]
cfDNA_TF_lower_OS_ci_high <- cfDNA_TF_summary_data_OS$table["cfDNA_TF_Baseline_binary=high", "0.95LCL"]
cfDNA_TF_upper_OS_ci_high <- cfDNA_TF_summary_data_OS$table["cfDNA_TF_Baseline_binary=high", "0.95UCL"]


# Create the survival plot
cfDNA_TF_OS_plot <- ggsurvplot(cfDNA_TF_OS_fit,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(40, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(40, 0.25),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("≥ 10%", "< 10%"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "Tumour Fraction",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             risk.table.fontsize = 5,
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "OS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)


# Annotate the median OS and confidence interval for low group
cfDNA_TF_OS_plot$plot <- cfDNA_TF_OS_plot$plot + 
  geom_label(aes(x = 35, y = 0.50, 
                 label = paste("Low TF\nMedian OS: ", round(cfDNA_TF_median_OS_low, 1), " months\n",
                               "95% CI: ", round(cfDNA_TF_lower_OS_ci_low, 1), "-", round(cfDNA_TF_upper_OS_ci_low, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 35, y = 0.80, 
                 label = paste("High TF\nMedian OS: ", cfDNA_TF_median_OS_high, " months\n",
                               "95% CI: ", round(cfDNA_TF_lower_OS_ci_high, 1), "-", round(cfDNA_TF_upper_OS_ci_high, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(cfDNA_TF_OS_plot)

# High-resolution plot saving
png("cfDNA_TF_OS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(cfDNA_TF_OS_plot)
dev.off()
## quartz_off_screen 
##                 2

1.34 Tumour Fraction as predictor for PFS

# Create binary variable for cfDNA Tumour Fraction (TF)
cfDNA_TF_Baseline_binary <- ifelse(ClinicData$Tumour_Fraction_ichorCNA_Baseline <= 0.10, "low", "high")
ClinicData$cfDNA_TF_Baseline_binary <- cfDNA_TF_Baseline_binary

# Fit the survival model for PFS
cfDNA_TF_PFS_fit <- survfit(Surv(Time_PFS, PFS_Status) ~ cfDNA_TF_Baseline_binary, data = ClinicData, conf.type = "log-log")
cfDNA_TF_summary_data_PFS <- summary(cfDNA_TF_PFS_fit)

# Extract median PFS and confidence intervals for each group
cfDNA_TF_median_PFS_low <- cfDNA_TF_summary_data_PFS$table["cfDNA_TF_Baseline_binary=low", "median"]
cfDNA_TF_lower_PFS_ci_low <- cfDNA_TF_summary_data_PFS$table["cfDNA_TF_Baseline_binary=low", "0.95LCL"]
cfDNA_TF_upper_PFS_ci_low <- cfDNA_TF_summary_data_PFS$table["cfDNA_TF_Baseline_binary=low", "0.95UCL"]

cfDNA_TF_median_PFS_high <- cfDNA_TF_summary_data_PFS$table["cfDNA_TF_Baseline_binary=high", "median"]
cfDNA_TF_lower_PFS_ci_high <- cfDNA_TF_summary_data_PFS$table["cfDNA_TF_Baseline_binary=high", "0.95LCL"]
cfDNA_TF_upper_PFS_ci_high <- cfDNA_TF_summary_data_PFS$table["cfDNA_TF_Baseline_binary=high", "0.95UCL"]


# Create the survival plot
cfDNA_TF_PFS_plot <- ggsurvplot(cfDNA_TF_PFS_fit,
                             conf.int = FALSE, # add confidence intervals
                             pval = TRUE, # show the p-value for the log-rank test
                             pval.method = TRUE, # show method for p-value
                             pval.size = 4, # p-value text size
                             pval.method.coord = c(30, 0.30), # <- move the "log-rank" method label here
                             pval.coord = c(30, 0.25),       # <- move the log-rank p-value here (x, y)
                             test.for.trend = FALSE,
                             risk.table = TRUE, # show a risk table below the plot
                             cumevents = FALSE,
                             cumcensor = FALSE,
                             surv.median.line = "hv", # horizontal/vertical line at median survival
                             legend.labs = c("≥ 10%", "< 10%"), # change group labels
                             tables.col = "strata",
                             tables.y.text.col = TRUE,
                             fontsize = 5,
                             legend.title = "Tumour Fraction",  # add legend title
                             risk.table.title = "Number at risk", # risk table title
                             risk.table.fontsize = 5,
                             title = NULL, # plot title
                             risk.table.height = 0.30,
                             add.all = FALSE,
                             combine = FALSE,
                             xlab = "Time, months",
                             ylab = "PFS Probability",
                             axes.offset = TRUE,
                             surv.plot.height = 1,
                             font.x = 15,
                             font.y = 15,
                             font.legend.title = 15)


# Annotate the median PFS and confidence interval for low group
cfDNA_TF_PFS_plot$plot <- cfDNA_TF_PFS_plot$plot + 
  geom_label(aes(x = 25, y = 0.50, 
                 label = paste("Low TF\nMedian PFS: ", round(cfDNA_TF_median_PFS_low, 1), " months\n",
                               "95% CI: ", round(cfDNA_TF_lower_PFS_ci_low, 1), "-", round(cfDNA_TF_upper_PFS_ci_low, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#00BFC4") +
  geom_label(aes(x = 25, y = 0.80, 
                 label = paste("High TF\nMedian PFS: ", cfDNA_TF_median_PFS_high, " months\n",
                               "95% CI: ", round(cfDNA_TF_lower_PFS_ci_high, 1), "-", round(cfDNA_TF_upper_PFS_ci_high, 1))),
             size = 4, hjust = 0, vjust = 1, color = "black", fill = "#F8766D")

# Print the plot in the R Markdown document
print(cfDNA_TF_PFS_plot)

# High-resolution plot saving
png("cfDNA_TF_PFS_TKI_ICI.png", width = 8, height = 8, units = "in", res = 500)
print(cfDNA_TF_PFS_plot)
dev.off()
## quartz_off_screen 
##                 2

2 Cox Regression Analysis.

2.1 Univariate analysis

2.1.0.1 Univariate Cox regression analysis for AFP level

library(dplyr)
library(survival)
library(gtsummary)

# Ensure AFP is numeric, then create binary: >400 = high, ≤400 = low
ClinicData <- ClinicData %>%
  mutate(
    AFP_num    = suppressWarnings(as.numeric(AFP)),
    AFP_binary = factor(ifelse(AFP_num > 400, "high", "low"), levels = c("low","high"))
  )

# Cox models
cox_model_OS_AFP <- coxph(Surv(Time_OS, OS_Status) ~ AFP_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of AFP >400 μg/L ('high') vs ≤400 μg/L ('low') on OS")

cox_model_PFS_AFP <- coxph(Surv(Time_PFS, PFS_Status) ~ AFP_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of AFP >400 μg/L ('high') vs ≤400 μg/L ('low') on PFS")

print(cox_model_OS_AFP)
## <div id="vexispxelv" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#vexispxelv table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #vexispxelv thead, #vexispxelv tbody, #vexispxelv tfoot, #vexispxelv tr, #vexispxelv td, #vexispxelv th {
##   border-style: none;
## }
## 
## #vexispxelv p {
##   margin: 0;
##   padding: 0;
## }
## 
## #vexispxelv .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #vexispxelv .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #vexispxelv .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #vexispxelv .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #vexispxelv .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #vexispxelv .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #vexispxelv .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #vexispxelv .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #vexispxelv .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #vexispxelv .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #vexispxelv .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #vexispxelv .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #vexispxelv .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #vexispxelv .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #vexispxelv .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vexispxelv .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #vexispxelv .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #vexispxelv .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #vexispxelv .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vexispxelv .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #vexispxelv .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vexispxelv .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #vexispxelv .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vexispxelv .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #vexispxelv .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vexispxelv .gt_left {
##   text-align: left;
## }
## 
## #vexispxelv .gt_center {
##   text-align: center;
## }
## 
## #vexispxelv .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #vexispxelv .gt_font_normal {
##   font-weight: normal;
## }
## 
## #vexispxelv .gt_font_bold {
##   font-weight: bold;
## }
## 
## #vexispxelv .gt_font_italic {
##   font-style: italic;
## }
## 
## #vexispxelv .gt_super {
##   font-size: 65%;
## }
## 
## #vexispxelv .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #vexispxelv .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #vexispxelv .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #vexispxelv .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #vexispxelv .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #vexispxelv .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #vexispxelv .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #vexispxelv .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #vexispxelv div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of AFP &gt;400 μg/L (‘high’) vs ≤400 μg/L (‘low’) on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">AFP_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">2.90</td>
## <td headers="conf.low" class="gt_row gt_center">1.87, 4.48</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_AFP)
## <div id="cwgehvsltg" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#cwgehvsltg table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #cwgehvsltg thead, #cwgehvsltg tbody, #cwgehvsltg tfoot, #cwgehvsltg tr, #cwgehvsltg td, #cwgehvsltg th {
##   border-style: none;
## }
## 
## #cwgehvsltg p {
##   margin: 0;
##   padding: 0;
## }
## 
## #cwgehvsltg .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #cwgehvsltg .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #cwgehvsltg .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #cwgehvsltg .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #cwgehvsltg .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #cwgehvsltg .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #cwgehvsltg .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #cwgehvsltg .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #cwgehvsltg .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #cwgehvsltg .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #cwgehvsltg .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #cwgehvsltg .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #cwgehvsltg .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #cwgehvsltg .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #cwgehvsltg .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #cwgehvsltg .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #cwgehvsltg .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #cwgehvsltg .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #cwgehvsltg .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #cwgehvsltg .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #cwgehvsltg .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #cwgehvsltg .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #cwgehvsltg .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #cwgehvsltg .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #cwgehvsltg .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #cwgehvsltg .gt_left {
##   text-align: left;
## }
## 
## #cwgehvsltg .gt_center {
##   text-align: center;
## }
## 
## #cwgehvsltg .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #cwgehvsltg .gt_font_normal {
##   font-weight: normal;
## }
## 
## #cwgehvsltg .gt_font_bold {
##   font-weight: bold;
## }
## 
## #cwgehvsltg .gt_font_italic {
##   font-style: italic;
## }
## 
## #cwgehvsltg .gt_super {
##   font-size: 65%;
## }
## 
## #cwgehvsltg .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #cwgehvsltg .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #cwgehvsltg .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #cwgehvsltg .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #cwgehvsltg .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #cwgehvsltg .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #cwgehvsltg .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #cwgehvsltg .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #cwgehvsltg div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of AFP &gt;400 μg/L (‘high’) vs ≤400 μg/L (‘low’) on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">AFP_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">1.98</td>
## <td headers="conf.low" class="gt_row gt_center">1.31, 3.00</td>
## <td headers="p.value" class="gt_row gt_center">0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.2 Univariate Cox regression analysis for response to TKI

ClinicData$Best_Responsce <- factor(ClinicData$Best_Responsce)
ClinicData$Best_Responsce <- relevel(ClinicData$Best_Responsce, ref = "SD")

# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_Responsce <- coxph(Surv(Time_OS, OS_Status) ~ Best_Responsce, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of best responsce on OS "))
Effect of best responsce on OS HR 95% CI p-value
Best_Responsce


    SD
    PD 2.94 1.97, 4.41 <0.001
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_Responsce <- coxph(Surv(Time_PFS, PFS_Status) ~ Best_Responsce, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of best responsce on PFS"))
Effect of best responsce on PFS HR 95% CI p-value
Best_Responsce


    SD
    PD 216 49.0, 956 <0.001
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio

2.1.0.3 Univariate Cox regression analysis for BCLC

library(dplyr)
library(survival)
library(gtsummary)

# Ensure unordered factor and set reference = "B"
ClinicData <- ClinicData %>%
  mutate(
    BCLC = as.character(BCLC),
    BCLC = factor(BCLC)
  )
if ("B" %in% levels(ClinicData$BCLC)) {
  ClinicData$BCLC <- relevel(ClinicData$BCLC, ref = "B")
} else {
  message("⚠️ 'B' not found in BCLC levels: ", paste(levels(ClinicData$BCLC), collapse = ", "))
}

# Cox PH models
cox_model_OS_BCLC <- coxph(Surv(Time_OS, OS_Status) ~ BCLC, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of BCLC stage on OS")

cox_model_PFS_BCLC <- coxph(Surv(Time_PFS, PFS_Status) ~ BCLC, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of BCLC stage on PFS")

print(cox_model_OS_BCLC)
## <div id="xutnystdhu" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#xutnystdhu table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #xutnystdhu thead, #xutnystdhu tbody, #xutnystdhu tfoot, #xutnystdhu tr, #xutnystdhu td, #xutnystdhu th {
##   border-style: none;
## }
## 
## #xutnystdhu p {
##   margin: 0;
##   padding: 0;
## }
## 
## #xutnystdhu .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #xutnystdhu .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #xutnystdhu .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #xutnystdhu .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #xutnystdhu .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #xutnystdhu .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #xutnystdhu .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #xutnystdhu .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #xutnystdhu .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #xutnystdhu .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #xutnystdhu .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #xutnystdhu .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #xutnystdhu .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #xutnystdhu .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #xutnystdhu .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #xutnystdhu .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #xutnystdhu .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #xutnystdhu .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #xutnystdhu .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #xutnystdhu .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #xutnystdhu .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #xutnystdhu .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #xutnystdhu .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #xutnystdhu .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #xutnystdhu .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #xutnystdhu .gt_left {
##   text-align: left;
## }
## 
## #xutnystdhu .gt_center {
##   text-align: center;
## }
## 
## #xutnystdhu .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #xutnystdhu .gt_font_normal {
##   font-weight: normal;
## }
## 
## #xutnystdhu .gt_font_bold {
##   font-weight: bold;
## }
## 
## #xutnystdhu .gt_font_italic {
##   font-style: italic;
## }
## 
## #xutnystdhu .gt_super {
##   font-size: 65%;
## }
## 
## #xutnystdhu .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #xutnystdhu .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #xutnystdhu .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #xutnystdhu .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #xutnystdhu .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #xutnystdhu .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #xutnystdhu .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #xutnystdhu .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #xutnystdhu div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of BCLC stage on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">BCLC</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    B</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    C</td>
## <td headers="estimate" class="gt_row gt_center">2.39</td>
## <td headers="conf.low" class="gt_row gt_center">1.52, 3.76</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_BCLC)
## <div id="fpamwlrukn" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#fpamwlrukn table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #fpamwlrukn thead, #fpamwlrukn tbody, #fpamwlrukn tfoot, #fpamwlrukn tr, #fpamwlrukn td, #fpamwlrukn th {
##   border-style: none;
## }
## 
## #fpamwlrukn p {
##   margin: 0;
##   padding: 0;
## }
## 
## #fpamwlrukn .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #fpamwlrukn .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #fpamwlrukn .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #fpamwlrukn .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #fpamwlrukn .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #fpamwlrukn .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #fpamwlrukn .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #fpamwlrukn .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #fpamwlrukn .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #fpamwlrukn .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #fpamwlrukn .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #fpamwlrukn .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #fpamwlrukn .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #fpamwlrukn .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #fpamwlrukn .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #fpamwlrukn .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #fpamwlrukn .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #fpamwlrukn .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #fpamwlrukn .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #fpamwlrukn .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #fpamwlrukn .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #fpamwlrukn .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #fpamwlrukn .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #fpamwlrukn .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #fpamwlrukn .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #fpamwlrukn .gt_left {
##   text-align: left;
## }
## 
## #fpamwlrukn .gt_center {
##   text-align: center;
## }
## 
## #fpamwlrukn .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #fpamwlrukn .gt_font_normal {
##   font-weight: normal;
## }
## 
## #fpamwlrukn .gt_font_bold {
##   font-weight: bold;
## }
## 
## #fpamwlrukn .gt_font_italic {
##   font-style: italic;
## }
## 
## #fpamwlrukn .gt_super {
##   font-size: 65%;
## }
## 
## #fpamwlrukn .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #fpamwlrukn .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #fpamwlrukn .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #fpamwlrukn .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #fpamwlrukn .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #fpamwlrukn .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #fpamwlrukn .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #fpamwlrukn .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #fpamwlrukn div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of BCLC stage on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">BCLC</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    B</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    C</td>
## <td headers="estimate" class="gt_row gt_center">2.96</td>
## <td headers="conf.low" class="gt_row gt_center">1.93, 4.56</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.4 Univariate Cox regression analysis for Age

# Convert Age_binary to factor and set reference level to "low"
ClinicData$Age_binary <- factor(ClinicData$Age_binary)
ClinicData$Age_binary <- relevel(ClinicData$Age_binary, ref = "low")

# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_Age <- coxph(Surv(Time_OS, OS_Status) ~ Age_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Age (years) > 70 'high' versus ≤ 70 'low' on OS"))
Effect of Age (years) > 70 ‘high’ versus ≤ 70 ‘low’ on OS HR 95% CI p-value
Age_binary


    low
    high 0.96 0.65, 1.42 0.8
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_Age <- coxph(Surv(Time_PFS, PFS_Status) ~ Age_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Age (years) > 70 'high' versus ≤ 70 'low' on PFS"))
Effect of Age (years) > 70 ‘high’ versus ≤ 70 ‘low’ on PFS HR 95% CI p-value
Age_binary


    low
    high 0.98 0.68, 1.42 >0.9
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio

2.1.0.5 Univariate Cox regression analysis for Tumour Size

# Convert Age_binary to factor and set reference level to "low"
ClinicData$TumourSize_binary <- factor(ClinicData$TumourSize_binary)
## Error in `$<-.data.frame`(`*tmp*`, TumourSize_binary, value = structure(integer(0), levels = character(0), class = "factor")): replacement has 0 rows, data has 134
ClinicData$TumourSize_binary <- relevel(ClinicData$TumourSize_binary, ref = "low")
## Error in relevel.default(ClinicData$TumourSize_binary, ref = "low"): 'relevel' only for (unordered) factors
# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_TumourSize <- coxph(Surv(Time_OS, OS_Status) ~ TumourSize_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Tumour size (cm) > 7 'high' versus ≤ 7 'low' on OS "))
Effect of Tumour size (cm) > 7 ‘high’ versus ≤ 7 ‘low’ on OS HR 95% CI p-value
TumourSize_binary


    high
    low 0.77 0.52, 1.15 0.2
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_TumourSize <- coxph(Surv(Time_PFS, PFS_Status) ~ TumourSize_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Tumour size (cm) > 7 'high' versus ≤ 7 'low' on PFS "))
Effect of Tumour size (cm) > 7 ‘high’ versus ≤ 7 ‘low’ on PFS HR 95% CI p-value
TumourSize_binary


    high
    low 0.72 0.50, 1.04 0.083
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio

2.1.0.6 Univariate Cox regression analysis for CTP

library(dplyr)
library(survival)
library(gtsummary)

# 1️⃣ Ensure CTP variable is a clean unordered factor with "A" as the reference
ClinicData <- ClinicData %>%
  mutate(
    CTP = as.character(CTP),       # Remove ordered factor if present
    CTP = factor(CTP),             # Convert to unordered factor
    CTP = relevel(CTP, ref = "A")  # Set "A" as reference level
  )

# ✅ Optional: check levels
print(levels(ClinicData$CTP))
## [1] "A" "B"
# 2️⃣ Cox model for Overall Survival (OS)
cox_model_OS_CTP <- coxph(Surv(Time_OS, OS_Status) ~ CTP, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of CTP Class on OS")

# 3️⃣ Cox model for Progression-Free Survival (PFS)
cox_model_PFS_CTP <- coxph(Surv(Time_PFS, PFS_Status) ~ CTP, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of CTP Class on PFS")

# 4️⃣ Print both results
print(cox_model_OS_CTP)
## <div id="ugvjsqgdwc" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#ugvjsqgdwc table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #ugvjsqgdwc thead, #ugvjsqgdwc tbody, #ugvjsqgdwc tfoot, #ugvjsqgdwc tr, #ugvjsqgdwc td, #ugvjsqgdwc th {
##   border-style: none;
## }
## 
## #ugvjsqgdwc p {
##   margin: 0;
##   padding: 0;
## }
## 
## #ugvjsqgdwc .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #ugvjsqgdwc .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #ugvjsqgdwc .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #ugvjsqgdwc .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #ugvjsqgdwc .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #ugvjsqgdwc .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #ugvjsqgdwc .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #ugvjsqgdwc .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #ugvjsqgdwc .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #ugvjsqgdwc .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #ugvjsqgdwc .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #ugvjsqgdwc .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #ugvjsqgdwc .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #ugvjsqgdwc .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #ugvjsqgdwc .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ugvjsqgdwc .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #ugvjsqgdwc .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #ugvjsqgdwc .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #ugvjsqgdwc .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ugvjsqgdwc .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #ugvjsqgdwc .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ugvjsqgdwc .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #ugvjsqgdwc .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ugvjsqgdwc .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #ugvjsqgdwc .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ugvjsqgdwc .gt_left {
##   text-align: left;
## }
## 
## #ugvjsqgdwc .gt_center {
##   text-align: center;
## }
## 
## #ugvjsqgdwc .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #ugvjsqgdwc .gt_font_normal {
##   font-weight: normal;
## }
## 
## #ugvjsqgdwc .gt_font_bold {
##   font-weight: bold;
## }
## 
## #ugvjsqgdwc .gt_font_italic {
##   font-style: italic;
## }
## 
## #ugvjsqgdwc .gt_super {
##   font-size: 65%;
## }
## 
## #ugvjsqgdwc .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #ugvjsqgdwc .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #ugvjsqgdwc .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #ugvjsqgdwc .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #ugvjsqgdwc .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #ugvjsqgdwc .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #ugvjsqgdwc .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #ugvjsqgdwc .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #ugvjsqgdwc div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of CTP Class on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">CTP</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    A</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    B</td>
## <td headers="estimate" class="gt_row gt_center">2.05</td>
## <td headers="conf.low" class="gt_row gt_center">1.18, 3.58</td>
## <td headers="p.value" class="gt_row gt_center">0.011</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_CTP)
## <div id="ddwukdbppc" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#ddwukdbppc table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #ddwukdbppc thead, #ddwukdbppc tbody, #ddwukdbppc tfoot, #ddwukdbppc tr, #ddwukdbppc td, #ddwukdbppc th {
##   border-style: none;
## }
## 
## #ddwukdbppc p {
##   margin: 0;
##   padding: 0;
## }
## 
## #ddwukdbppc .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #ddwukdbppc .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #ddwukdbppc .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #ddwukdbppc .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #ddwukdbppc .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #ddwukdbppc .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #ddwukdbppc .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #ddwukdbppc .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #ddwukdbppc .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #ddwukdbppc .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #ddwukdbppc .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #ddwukdbppc .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #ddwukdbppc .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #ddwukdbppc .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #ddwukdbppc .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ddwukdbppc .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #ddwukdbppc .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #ddwukdbppc .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #ddwukdbppc .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ddwukdbppc .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #ddwukdbppc .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ddwukdbppc .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #ddwukdbppc .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ddwukdbppc .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #ddwukdbppc .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #ddwukdbppc .gt_left {
##   text-align: left;
## }
## 
## #ddwukdbppc .gt_center {
##   text-align: center;
## }
## 
## #ddwukdbppc .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #ddwukdbppc .gt_font_normal {
##   font-weight: normal;
## }
## 
## #ddwukdbppc .gt_font_bold {
##   font-weight: bold;
## }
## 
## #ddwukdbppc .gt_font_italic {
##   font-style: italic;
## }
## 
## #ddwukdbppc .gt_super {
##   font-size: 65%;
## }
## 
## #ddwukdbppc .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #ddwukdbppc .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #ddwukdbppc .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #ddwukdbppc .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #ddwukdbppc .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #ddwukdbppc .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #ddwukdbppc .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #ddwukdbppc .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #ddwukdbppc div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of CTP Class on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">CTP</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    A</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    B</td>
## <td headers="estimate" class="gt_row gt_center">2.40</td>
## <td headers="conf.low" class="gt_row gt_center">1.39, 4.14</td>
## <td headers="p.value" class="gt_row gt_center">0.002</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.7 Univariate Cox regression analysis for PS

library(dplyr)
library(survival)
library(gtsummary)

# 1️⃣ Ensure PS is an unordered factor before releveling
ClinicData <- ClinicData %>%
  mutate(
    PS = as.character(PS),          # Convert to character (removes ordering)
    PS = factor(PS),                # Convert to unordered factor
    PS = relevel(PS, ref = "0")     # Set "0" as reference level
  )

# 🛑 Optional: Check available levels
print(levels(ClinicData$PS))
## [1] "0" "1" "2"
# 2️⃣ Cox model for Overall Survival (OS)
cox_model_OS_PS <- coxph(Surv(Time_OS, OS_Status) ~ PS, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of Performance Status (PS) on OS")

# 3️⃣ Cox model for Progression-Free Survival (PFS)
cox_model_PFS_PS <- coxph(Surv(Time_PFS, PFS_Status) ~ PS, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Effect of Performance Status (PS) on PFS")

# 4️⃣ Print results
print(cox_model_OS_PS)
## <div id="rjzmmscshd" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#rjzmmscshd table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #rjzmmscshd thead, #rjzmmscshd tbody, #rjzmmscshd tfoot, #rjzmmscshd tr, #rjzmmscshd td, #rjzmmscshd th {
##   border-style: none;
## }
## 
## #rjzmmscshd p {
##   margin: 0;
##   padding: 0;
## }
## 
## #rjzmmscshd .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #rjzmmscshd .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #rjzmmscshd .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #rjzmmscshd .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #rjzmmscshd .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #rjzmmscshd .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #rjzmmscshd .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #rjzmmscshd .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #rjzmmscshd .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #rjzmmscshd .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #rjzmmscshd .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #rjzmmscshd .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #rjzmmscshd .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #rjzmmscshd .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #rjzmmscshd .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #rjzmmscshd .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #rjzmmscshd .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #rjzmmscshd .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #rjzmmscshd .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #rjzmmscshd .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #rjzmmscshd .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #rjzmmscshd .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #rjzmmscshd .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #rjzmmscshd .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #rjzmmscshd .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #rjzmmscshd .gt_left {
##   text-align: left;
## }
## 
## #rjzmmscshd .gt_center {
##   text-align: center;
## }
## 
## #rjzmmscshd .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #rjzmmscshd .gt_font_normal {
##   font-weight: normal;
## }
## 
## #rjzmmscshd .gt_font_bold {
##   font-weight: bold;
## }
## 
## #rjzmmscshd .gt_font_italic {
##   font-style: italic;
## }
## 
## #rjzmmscshd .gt_super {
##   font-size: 65%;
## }
## 
## #rjzmmscshd .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #rjzmmscshd .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #rjzmmscshd .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #rjzmmscshd .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #rjzmmscshd .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #rjzmmscshd .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #rjzmmscshd .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #rjzmmscshd .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #rjzmmscshd div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of Performance Status (PS) on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">PS</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    0</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    1</td>
## <td headers="estimate" class="gt_row gt_center">1.56</td>
## <td headers="conf.low" class="gt_row gt_center">1.02, 2.39</td>
## <td headers="p.value" class="gt_row gt_center">0.042</td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    2</td>
## <td headers="estimate" class="gt_row gt_center">4.30</td>
## <td headers="conf.low" class="gt_row gt_center">2.01, 9.18</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_PS)
## <div id="sbuahhbmwf" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#sbuahhbmwf table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #sbuahhbmwf thead, #sbuahhbmwf tbody, #sbuahhbmwf tfoot, #sbuahhbmwf tr, #sbuahhbmwf td, #sbuahhbmwf th {
##   border-style: none;
## }
## 
## #sbuahhbmwf p {
##   margin: 0;
##   padding: 0;
## }
## 
## #sbuahhbmwf .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #sbuahhbmwf .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #sbuahhbmwf .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #sbuahhbmwf .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #sbuahhbmwf .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #sbuahhbmwf .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #sbuahhbmwf .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #sbuahhbmwf .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #sbuahhbmwf .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #sbuahhbmwf .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #sbuahhbmwf .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #sbuahhbmwf .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #sbuahhbmwf .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #sbuahhbmwf .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #sbuahhbmwf .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #sbuahhbmwf .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #sbuahhbmwf .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #sbuahhbmwf .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #sbuahhbmwf .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #sbuahhbmwf .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #sbuahhbmwf .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #sbuahhbmwf .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #sbuahhbmwf .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #sbuahhbmwf .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #sbuahhbmwf .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #sbuahhbmwf .gt_left {
##   text-align: left;
## }
## 
## #sbuahhbmwf .gt_center {
##   text-align: center;
## }
## 
## #sbuahhbmwf .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #sbuahhbmwf .gt_font_normal {
##   font-weight: normal;
## }
## 
## #sbuahhbmwf .gt_font_bold {
##   font-weight: bold;
## }
## 
## #sbuahhbmwf .gt_font_italic {
##   font-style: italic;
## }
## 
## #sbuahhbmwf .gt_super {
##   font-size: 65%;
## }
## 
## #sbuahhbmwf .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #sbuahhbmwf .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #sbuahhbmwf .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #sbuahhbmwf .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #sbuahhbmwf .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #sbuahhbmwf .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #sbuahhbmwf .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #sbuahhbmwf .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #sbuahhbmwf div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of Performance Status (PS) on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">PS</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    0</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    1</td>
## <td headers="estimate" class="gt_row gt_center">1.68</td>
## <td headers="conf.low" class="gt_row gt_center">1.13, 2.49</td>
## <td headers="p.value" class="gt_row gt_center">0.010</td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    2</td>
## <td headers="estimate" class="gt_row gt_center">3.17</td>
## <td headers="conf.low" class="gt_row gt_center">1.52, 6.63</td>
## <td headers="p.value" class="gt_row gt_center">0.002</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.8 Univariate Cox regression analysis for HAP class

ClinicData$HAP_class <- factor(ClinicData$HAP_class)
## Error in `$<-.data.frame`(`*tmp*`, HAP_class, value = structure(integer(0), levels = character(0), class = "factor")): replacement has 0 rows, data has 134
ClinicData$HAP_class <- relevel(ClinicData$HAP_class, ref = "A")
## Error in relevel.default(ClinicData$HAP_class, ref = "A"): 'relevel' only for (unordered) factors
# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_HAP_class <- coxph(Surv(Time_OS, OS_Status) ~ HAP_class, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of HAP class on OS "))
## Error in eval(predvars, data, env): object 'HAP_class' not found
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_HAP_class <- coxph(Surv(Time_PFS, PFS_Status) ~ HAP_class, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of HAP class on PFS "))
## Error in eval(predvars, data, env): object 'HAP_class' not found

2.1.0.9 Univariate Cox regression analysis for Gender

ClinicData$Gender <- factor(ClinicData$Gender)
ClinicData$Gender <- relevel(ClinicData$Gender, ref = "Female")

# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_Gender <- coxph(Surv(Time_OS, OS_Status) ~ Gender, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Geneder on OS "))
Effect of Geneder on OS HR 95% CI p-value
Gender


    Female
    Male 1.31 0.73, 2.35 0.4
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_Gender <- coxph(Surv(Time_PFS, PFS_Status) ~ Gender, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Geneder on PFS "))
Effect of Geneder on PFS HR 95% CI p-value
Gender


    Female
    Male 1.19 0.70, 2.02 0.5
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio

2.1.0.10 Univariate Cox regression analysis for Viral_Not_Viral

ClinicData$Viral_Not_Viral <- factor(ClinicData$Viral_Not_Viral)
## Error in `$<-.data.frame`(`*tmp*`, Viral_Not_Viral, value = structure(integer(0), levels = character(0), class = "factor")): replacement has 0 rows, data has 134
ClinicData$Viral_Not_Viral <- relevel(ClinicData$Viral_Not_Viral, ref = "Non-viral")
## Error in relevel.default(ClinicData$Viral_Not_Viral, ref = "Non-viral"): 'relevel' only for (unordered) factors
# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_Viral_Not_Viral <- coxph(Surv(Time_OS, OS_Status) ~ Viral_Not_Viral, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Viral and non-Viral aetiology on OS "))
## Error in eval(predvars, data, env): object 'Viral_Not_Viral' not found
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_Viral_Not_Viral <- coxph(Surv(Time_PFS, PFS_Status) ~ Viral_Not_Viral, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of Viral and non-Viral aetiology on PFS "))
## Error in eval(predvars, data, env): object 'Viral_Not_Viral' not found

2.1.0.11 Univariate Cox regression analysis for Cirrhosis

ClinicData$Cirrhosis <- factor(ClinicData$Cirrhosis)
ClinicData$Cirrhosis <- relevel(ClinicData$Cirrhosis, ref = "NO")

# Fit the Cox proportional hazards model for Overall Survival
(cox_model_OS_Cirrhosis <- coxph(Surv(Time_OS, OS_Status) ~ Cirrhosis, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of present of Cirrhosis on OS "))
Effect of present of Cirrhosis on OS HR 95% CI p-value
Cirrhosis


    NO
    Cirrhosis 0.98 0.48, 2.00 >0.9
    YES 1.48 0.77, 2.81 0.2
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
# Fit the Cox proportional hazards model for Progression-Free Survival
(cox_model_PFS_Cirrhosis <- coxph(Surv(Time_PFS, PFS_Status) ~ Cirrhosis, data = ClinicData) %>%
  tbl_regression(exp = TRUE)%>%
  modify_header(label = "Effect of present of Cirrhosis on PFS "))
Effect of present of Cirrhosis on PFS HR 95% CI p-value
Cirrhosis


    NO
    Cirrhosis 1.06 0.55, 2.06 0.9
    YES 1.78 0.95, 3.32 0.070
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio

2.1.0.12 Univariate Cox regression analysis for PVT_EHS

library(dplyr)
library(survival)
library(gtsummary)

# Clean/standardize PVT and set reference = "No"
ClinicData <- ClinicData %>%
  mutate(
    PVT = tolower(trimws(as.character(PVT))),
    PVT = case_when(
      PVT %in% c("yes","present","1","y","true") ~ "Yes",
      PVT %in% c("no","absent","0","n","false") ~ "No",
      TRUE ~ tools::toTitleCase(PVT)            # keep existing if already "Yes"/"No"
    ),
    PVT = factor(PVT, levels = c("No","Yes"))   # 'No' is the reference
  )

# Cox PH: Overall Survival
cox_model_OS_PVT <-
  coxph(Surv(Time_OS, OS_Status) ~ PVT, data = ClinicData) |>
  tbl_regression(exp = TRUE) |>
  modify_header(label = "Effect of presence of PVT on OS")

# Cox PH: Progression-Free Survival
cox_model_PFS_PVT <-
  coxph(Surv(Time_PFS, PFS_Status) ~ PVT, data = ClinicData) |>
  tbl_regression(exp = TRUE) |>
  modify_header(label = "Effect of presence of PVT on PFS")

# Print tables
print(cox_model_OS_PVT)
## <div id="bnfjofnpoi" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#bnfjofnpoi table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #bnfjofnpoi thead, #bnfjofnpoi tbody, #bnfjofnpoi tfoot, #bnfjofnpoi tr, #bnfjofnpoi td, #bnfjofnpoi th {
##   border-style: none;
## }
## 
## #bnfjofnpoi p {
##   margin: 0;
##   padding: 0;
## }
## 
## #bnfjofnpoi .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #bnfjofnpoi .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #bnfjofnpoi .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #bnfjofnpoi .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #bnfjofnpoi .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #bnfjofnpoi .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #bnfjofnpoi .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #bnfjofnpoi .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #bnfjofnpoi .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #bnfjofnpoi .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #bnfjofnpoi .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #bnfjofnpoi .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #bnfjofnpoi .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #bnfjofnpoi .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #bnfjofnpoi .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #bnfjofnpoi .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #bnfjofnpoi .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #bnfjofnpoi .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #bnfjofnpoi .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #bnfjofnpoi .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #bnfjofnpoi .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #bnfjofnpoi .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #bnfjofnpoi .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #bnfjofnpoi .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #bnfjofnpoi .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #bnfjofnpoi .gt_left {
##   text-align: left;
## }
## 
## #bnfjofnpoi .gt_center {
##   text-align: center;
## }
## 
## #bnfjofnpoi .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #bnfjofnpoi .gt_font_normal {
##   font-weight: normal;
## }
## 
## #bnfjofnpoi .gt_font_bold {
##   font-weight: bold;
## }
## 
## #bnfjofnpoi .gt_font_italic {
##   font-style: italic;
## }
## 
## #bnfjofnpoi .gt_super {
##   font-size: 65%;
## }
## 
## #bnfjofnpoi .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #bnfjofnpoi .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #bnfjofnpoi .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #bnfjofnpoi .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #bnfjofnpoi .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #bnfjofnpoi .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #bnfjofnpoi .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #bnfjofnpoi .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #bnfjofnpoi div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of presence of PVT on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">PVT</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    No</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    Yes</td>
## <td headers="estimate" class="gt_row gt_center">2.11</td>
## <td headers="conf.low" class="gt_row gt_center">1.41, 3.16</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_PVT)
## <div id="uzqyhgvdeg" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#uzqyhgvdeg table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #uzqyhgvdeg thead, #uzqyhgvdeg tbody, #uzqyhgvdeg tfoot, #uzqyhgvdeg tr, #uzqyhgvdeg td, #uzqyhgvdeg th {
##   border-style: none;
## }
## 
## #uzqyhgvdeg p {
##   margin: 0;
##   padding: 0;
## }
## 
## #uzqyhgvdeg .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #uzqyhgvdeg .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #uzqyhgvdeg .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #uzqyhgvdeg .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #uzqyhgvdeg .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #uzqyhgvdeg .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #uzqyhgvdeg .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #uzqyhgvdeg .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #uzqyhgvdeg .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #uzqyhgvdeg .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #uzqyhgvdeg .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #uzqyhgvdeg .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #uzqyhgvdeg .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #uzqyhgvdeg .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #uzqyhgvdeg .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #uzqyhgvdeg .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #uzqyhgvdeg .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #uzqyhgvdeg .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #uzqyhgvdeg .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #uzqyhgvdeg .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #uzqyhgvdeg .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #uzqyhgvdeg .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #uzqyhgvdeg .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #uzqyhgvdeg .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #uzqyhgvdeg .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #uzqyhgvdeg .gt_left {
##   text-align: left;
## }
## 
## #uzqyhgvdeg .gt_center {
##   text-align: center;
## }
## 
## #uzqyhgvdeg .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #uzqyhgvdeg .gt_font_normal {
##   font-weight: normal;
## }
## 
## #uzqyhgvdeg .gt_font_bold {
##   font-weight: bold;
## }
## 
## #uzqyhgvdeg .gt_font_italic {
##   font-style: italic;
## }
## 
## #uzqyhgvdeg .gt_super {
##   font-size: 65%;
## }
## 
## #uzqyhgvdeg .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #uzqyhgvdeg .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #uzqyhgvdeg .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #uzqyhgvdeg .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #uzqyhgvdeg .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #uzqyhgvdeg .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #uzqyhgvdeg .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #uzqyhgvdeg .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #uzqyhgvdeg div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of presence of PVT on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">PVT</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    No</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    Yes</td>
## <td headers="estimate" class="gt_row gt_center">2.90</td>
## <td headers="conf.low" class="gt_row gt_center">1.96, 4.28</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.13 Univariate Cox regression analysis for Treatment_Type

library(dplyr)
library(stringr)
library(survival)
library(gtsummary)

# Factor + reference
ClinicData$Treatment_Class <- factor(ClinicData$Treatment_Class)
if ("TKI" %in% levels(ClinicData$Treatment_Class)) {
  ClinicData$Treatment_Class <- relevel(ClinicData$Treatment_Class, ref = "TKI")
}

# Cox models
library(survival)
library(gtsummary)

cox_model_OS_Treatment_Class <-
  coxph(Surv(Time_OS, OS_Status) ~ Treatment_Class, data = ClinicData) |>
  tbl_regression(exp = TRUE) |>
  modify_header(label = "Effect of Treatment Class on OS")

cox_model_PFS_Treatment_Class <-
  coxph(Surv(Time_PFS, PFS_Status) ~ Treatment_Class, data = ClinicData) |>
  tbl_regression(exp = TRUE) |>
  modify_header(label = "Effect of Treatment Class on PFS")

print(cox_model_OS_Treatment_Class)
## <div id="zsmtykoesu" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#zsmtykoesu table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #zsmtykoesu thead, #zsmtykoesu tbody, #zsmtykoesu tfoot, #zsmtykoesu tr, #zsmtykoesu td, #zsmtykoesu th {
##   border-style: none;
## }
## 
## #zsmtykoesu p {
##   margin: 0;
##   padding: 0;
## }
## 
## #zsmtykoesu .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #zsmtykoesu .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #zsmtykoesu .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #zsmtykoesu .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #zsmtykoesu .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #zsmtykoesu .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #zsmtykoesu .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #zsmtykoesu .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #zsmtykoesu .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #zsmtykoesu .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #zsmtykoesu .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #zsmtykoesu .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #zsmtykoesu .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #zsmtykoesu .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #zsmtykoesu .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #zsmtykoesu .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #zsmtykoesu .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #zsmtykoesu .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #zsmtykoesu .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #zsmtykoesu .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #zsmtykoesu .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #zsmtykoesu .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #zsmtykoesu .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #zsmtykoesu .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #zsmtykoesu .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #zsmtykoesu .gt_left {
##   text-align: left;
## }
## 
## #zsmtykoesu .gt_center {
##   text-align: center;
## }
## 
## #zsmtykoesu .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #zsmtykoesu .gt_font_normal {
##   font-weight: normal;
## }
## 
## #zsmtykoesu .gt_font_bold {
##   font-weight: bold;
## }
## 
## #zsmtykoesu .gt_font_italic {
##   font-style: italic;
## }
## 
## #zsmtykoesu .gt_super {
##   font-size: 65%;
## }
## 
## #zsmtykoesu .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #zsmtykoesu .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #zsmtykoesu .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #zsmtykoesu .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #zsmtykoesu .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #zsmtykoesu .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #zsmtykoesu .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #zsmtykoesu .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #zsmtykoesu div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of Treatment Class on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">Treatment_Class</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    TKI</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    ICI</td>
## <td headers="estimate" class="gt_row gt_center">0.71</td>
## <td headers="conf.low" class="gt_row gt_center">0.45, 1.12</td>
## <td headers="p.value" class="gt_row gt_center">0.14</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_Treatment_Class)
## <div id="myrflyrclb" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#myrflyrclb table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #myrflyrclb thead, #myrflyrclb tbody, #myrflyrclb tfoot, #myrflyrclb tr, #myrflyrclb td, #myrflyrclb th {
##   border-style: none;
## }
## 
## #myrflyrclb p {
##   margin: 0;
##   padding: 0;
## }
## 
## #myrflyrclb .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #myrflyrclb .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #myrflyrclb .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #myrflyrclb .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #myrflyrclb .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #myrflyrclb .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #myrflyrclb .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #myrflyrclb .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #myrflyrclb .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #myrflyrclb .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #myrflyrclb .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #myrflyrclb .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #myrflyrclb .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #myrflyrclb .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #myrflyrclb .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #myrflyrclb .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #myrflyrclb .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #myrflyrclb .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #myrflyrclb .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #myrflyrclb .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #myrflyrclb .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #myrflyrclb .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #myrflyrclb .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #myrflyrclb .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #myrflyrclb .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #myrflyrclb .gt_left {
##   text-align: left;
## }
## 
## #myrflyrclb .gt_center {
##   text-align: center;
## }
## 
## #myrflyrclb .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #myrflyrclb .gt_font_normal {
##   font-weight: normal;
## }
## 
## #myrflyrclb .gt_font_bold {
##   font-weight: bold;
## }
## 
## #myrflyrclb .gt_font_italic {
##   font-style: italic;
## }
## 
## #myrflyrclb .gt_super {
##   font-size: 65%;
## }
## 
## #myrflyrclb .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #myrflyrclb .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #myrflyrclb .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #myrflyrclb .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #myrflyrclb .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #myrflyrclb .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #myrflyrclb .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #myrflyrclb .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #myrflyrclb div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of Treatment Class on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">Treatment_Class</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    TKI</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    ICI</td>
## <td headers="estimate" class="gt_row gt_center">0.67</td>
## <td headers="conf.low" class="gt_row gt_center">0.45, 1.00</td>
## <td headers="p.value" class="gt_row gt_center">0.048</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.14 Univariate Cox regression analysis for Tumour Fraction

library(dplyr)
library(survival)
library(gtsummary)

# ✅ 1. Create a clean binary variable (≤10% = low, >10% = high)
ClinicData <- ClinicData %>%
  mutate(
    cfDNA_TF_Baseline_binary = ifelse(Tumour_Fraction_ichorCNA_Baseline > 0.10, "high", "low"),
    cfDNA_TF_Baseline_binary = factor(cfDNA_TF_Baseline_binary, levels = c("low", "high"))
  )

# ✅ 2. Fit Cox model for Overall Survival (OS)
cox_model_OS_TumourFraction <- coxph(Surv(Time_OS, OS_Status) ~ cfDNA_TF_Baseline_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Tumour Fraction >10% (high) vs ≤10% (low) – OS")

# ✅ 3. Fit Cox model for Progression-Free Survival (PFS)
cox_model_PFS_TumourFraction <- coxph(Surv(Time_PFS, PFS_Status) ~ cfDNA_TF_Baseline_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "Tumour Fraction >10% (high) vs ≤10% (low) – PFS")

# ✅ 4. Print the results to R Markdown console/output
print(cox_model_OS_TumourFraction)
## <div id="mwxleixrgh" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#mwxleixrgh table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #mwxleixrgh thead, #mwxleixrgh tbody, #mwxleixrgh tfoot, #mwxleixrgh tr, #mwxleixrgh td, #mwxleixrgh th {
##   border-style: none;
## }
## 
## #mwxleixrgh p {
##   margin: 0;
##   padding: 0;
## }
## 
## #mwxleixrgh .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #mwxleixrgh .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #mwxleixrgh .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #mwxleixrgh .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #mwxleixrgh .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #mwxleixrgh .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #mwxleixrgh .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #mwxleixrgh .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #mwxleixrgh .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #mwxleixrgh .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #mwxleixrgh .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #mwxleixrgh .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #mwxleixrgh .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #mwxleixrgh .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #mwxleixrgh .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #mwxleixrgh .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #mwxleixrgh .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #mwxleixrgh .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #mwxleixrgh .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #mwxleixrgh .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #mwxleixrgh .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #mwxleixrgh .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #mwxleixrgh .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #mwxleixrgh .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #mwxleixrgh .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #mwxleixrgh .gt_left {
##   text-align: left;
## }
## 
## #mwxleixrgh .gt_center {
##   text-align: center;
## }
## 
## #mwxleixrgh .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #mwxleixrgh .gt_font_normal {
##   font-weight: normal;
## }
## 
## #mwxleixrgh .gt_font_bold {
##   font-weight: bold;
## }
## 
## #mwxleixrgh .gt_font_italic {
##   font-style: italic;
## }
## 
## #mwxleixrgh .gt_super {
##   font-size: 65%;
## }
## 
## #mwxleixrgh .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #mwxleixrgh .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #mwxleixrgh .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #mwxleixrgh .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #mwxleixrgh .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #mwxleixrgh .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #mwxleixrgh .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #mwxleixrgh .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #mwxleixrgh div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Tumour Fraction &gt;10% (high) vs ≤10% (low) – OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">cfDNA_TF_Baseline_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">1.62</td>
## <td headers="conf.low" class="gt_row gt_center">1.06, 2.47</td>
## <td headers="p.value" class="gt_row gt_center">0.024</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_TumourFraction)
## <div id="joeejwrqzq" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#joeejwrqzq table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #joeejwrqzq thead, #joeejwrqzq tbody, #joeejwrqzq tfoot, #joeejwrqzq tr, #joeejwrqzq td, #joeejwrqzq th {
##   border-style: none;
## }
## 
## #joeejwrqzq p {
##   margin: 0;
##   padding: 0;
## }
## 
## #joeejwrqzq .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #joeejwrqzq .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #joeejwrqzq .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #joeejwrqzq .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #joeejwrqzq .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #joeejwrqzq .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #joeejwrqzq .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #joeejwrqzq .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #joeejwrqzq .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #joeejwrqzq .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #joeejwrqzq .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #joeejwrqzq .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #joeejwrqzq .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #joeejwrqzq .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #joeejwrqzq .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #joeejwrqzq .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #joeejwrqzq .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #joeejwrqzq .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #joeejwrqzq .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #joeejwrqzq .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #joeejwrqzq .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #joeejwrqzq .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #joeejwrqzq .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #joeejwrqzq .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #joeejwrqzq .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #joeejwrqzq .gt_left {
##   text-align: left;
## }
## 
## #joeejwrqzq .gt_center {
##   text-align: center;
## }
## 
## #joeejwrqzq .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #joeejwrqzq .gt_font_normal {
##   font-weight: normal;
## }
## 
## #joeejwrqzq .gt_font_bold {
##   font-weight: bold;
## }
## 
## #joeejwrqzq .gt_font_italic {
##   font-style: italic;
## }
## 
## #joeejwrqzq .gt_super {
##   font-size: 65%;
## }
## 
## #joeejwrqzq .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #joeejwrqzq .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #joeejwrqzq .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #joeejwrqzq .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #joeejwrqzq .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #joeejwrqzq .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #joeejwrqzq .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #joeejwrqzq .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #joeejwrqzq div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Tumour Fraction &gt;10% (high) vs ≤10% (low) – PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">cfDNA_TF_Baseline_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">2.13</td>
## <td headers="conf.low" class="gt_row gt_center">1.43, 3.16</td>
## <td headers="p.value" class="gt_row gt_center"><0.001</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.15 Univariate Cox regression analysis for tMAD

# ───────────────────────────────────────────────────────────────
# Cox proportional hazards model for tMAD (binary: >0.02 vs ≤0.02)
# ───────────────────────────────────────────────────────────────

library(dplyr)
library(survival)
library(gtsummary)

# 1️⃣ Create binary variable based on threshold 0.02
ClinicData <- ClinicData %>%
  mutate(
    tMAD_binary = ifelse(tMAD > 0.02, "high", "low"),
    tMAD_binary = factor(tMAD_binary, levels = c("low", "high")) # 'low' as reference
  )

# Sanity check
table(ClinicData$tMAD_binary, useNA = "ifany")
## 
##  low high 
##   95   39
# 2️⃣ Cox proportional hazards model for Overall Survival (OS)
cox_model_OS_tMAD <- coxph(Surv(Time_OS, OS_Status) ~ tMAD_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "tMAD score > 0.02 ('high') versus ≤ 0.02 ('low') on OS")

# 3️⃣ Cox proportional hazards model for Progression-Free Survival (PFS)
cox_model_PFS_tMAD <- coxph(Surv(Time_PFS, PFS_Status) ~ tMAD_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = "tMAD score > 0.02 ('high') versus ≤ 0.02 ('low') on PFS")

# 4️⃣ Print both results to the R Markdown output
print(cox_model_OS_tMAD)
## <div id="wizkkddhsf" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#wizkkddhsf table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #wizkkddhsf thead, #wizkkddhsf tbody, #wizkkddhsf tfoot, #wizkkddhsf tr, #wizkkddhsf td, #wizkkddhsf th {
##   border-style: none;
## }
## 
## #wizkkddhsf p {
##   margin: 0;
##   padding: 0;
## }
## 
## #wizkkddhsf .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #wizkkddhsf .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #wizkkddhsf .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #wizkkddhsf .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #wizkkddhsf .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #wizkkddhsf .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #wizkkddhsf .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #wizkkddhsf .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #wizkkddhsf .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #wizkkddhsf .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #wizkkddhsf .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #wizkkddhsf .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #wizkkddhsf .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #wizkkddhsf .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #wizkkddhsf .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #wizkkddhsf .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #wizkkddhsf .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #wizkkddhsf .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #wizkkddhsf .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #wizkkddhsf .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #wizkkddhsf .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #wizkkddhsf .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #wizkkddhsf .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #wizkkddhsf .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #wizkkddhsf .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #wizkkddhsf .gt_left {
##   text-align: left;
## }
## 
## #wizkkddhsf .gt_center {
##   text-align: center;
## }
## 
## #wizkkddhsf .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #wizkkddhsf .gt_font_normal {
##   font-weight: normal;
## }
## 
## #wizkkddhsf .gt_font_bold {
##   font-weight: bold;
## }
## 
## #wizkkddhsf .gt_font_italic {
##   font-style: italic;
## }
## 
## #wizkkddhsf .gt_super {
##   font-size: 65%;
## }
## 
## #wizkkddhsf .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #wizkkddhsf .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #wizkkddhsf .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #wizkkddhsf .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #wizkkddhsf .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #wizkkddhsf .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #wizkkddhsf .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #wizkkddhsf .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #wizkkddhsf div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>tMAD score &gt; 0.02 (‘high’) versus ≤ 0.02 (‘low’) on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">tMAD_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">1.52</td>
## <td headers="conf.low" class="gt_row gt_center">0.97, 2.38</td>
## <td headers="p.value" class="gt_row gt_center">0.065</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_tMAD)
## <div id="oigmhnzqys" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#oigmhnzqys table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #oigmhnzqys thead, #oigmhnzqys tbody, #oigmhnzqys tfoot, #oigmhnzqys tr, #oigmhnzqys td, #oigmhnzqys th {
##   border-style: none;
## }
## 
## #oigmhnzqys p {
##   margin: 0;
##   padding: 0;
## }
## 
## #oigmhnzqys .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #oigmhnzqys .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #oigmhnzqys .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #oigmhnzqys .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #oigmhnzqys .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #oigmhnzqys .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #oigmhnzqys .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #oigmhnzqys .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #oigmhnzqys .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #oigmhnzqys .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #oigmhnzqys .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #oigmhnzqys .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #oigmhnzqys .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #oigmhnzqys .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #oigmhnzqys .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #oigmhnzqys .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #oigmhnzqys .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #oigmhnzqys .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #oigmhnzqys .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #oigmhnzqys .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #oigmhnzqys .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #oigmhnzqys .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #oigmhnzqys .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #oigmhnzqys .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #oigmhnzqys .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #oigmhnzqys .gt_left {
##   text-align: left;
## }
## 
## #oigmhnzqys .gt_center {
##   text-align: center;
## }
## 
## #oigmhnzqys .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #oigmhnzqys .gt_font_normal {
##   font-weight: normal;
## }
## 
## #oigmhnzqys .gt_font_bold {
##   font-weight: bold;
## }
## 
## #oigmhnzqys .gt_font_italic {
##   font-style: italic;
## }
## 
## #oigmhnzqys .gt_super {
##   font-size: 65%;
## }
## 
## #oigmhnzqys .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #oigmhnzqys .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #oigmhnzqys .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #oigmhnzqys .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #oigmhnzqys .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #oigmhnzqys .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #oigmhnzqys .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #oigmhnzqys .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #oigmhnzqys div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>tMAD score &gt; 0.02 (‘high’) versus ≤ 0.02 (‘low’) on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">tMAD_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">1.28</td>
## <td headers="conf.low" class="gt_row gt_center">0.85, 1.93</td>
## <td headers="p.value" class="gt_row gt_center">0.2</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.16 Univariate Cox regression analysis for DELFI

library(dplyr)
library(survival)
library(gtsummary)

# 1) Create binary from DELFI_Baseline (threshold 0.4)
ClinicData <- ClinicData %>%
  mutate(
    DELFI_binary = ifelse(DELFI_Baseline > 0.287, "high", "low"),
    DELFI_binary = factor(DELFI_binary, levels = c("low","high"))  # 'low' = reference
  )

# optional sanity check
# table(ClinicData$DELFI_binary, useNA = "ifany")

# 2) Cox models
label_OS  <- "DELFI score > 0.4 ('high') versus ≤ 0.4 ('low') on OS"
label_PFS <- "DELFI score > 0.4 ('high') versus ≤ 0.4 ('low') on PFS"

cox_model_OS_DELFI <-
  coxph(Surv(Time_OS, OS_Status) ~ DELFI_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = label_OS)

cox_model_PFS_DELFI <-
  coxph(Surv(Time_PFS, PFS_Status) ~ DELFI_binary, data = ClinicData) %>%
  tbl_regression(exp = TRUE) %>%
  modify_header(label = label_PFS)

# 3) Print results
print(cox_model_OS_DELFI)
## <div id="vfyakpvewb" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#vfyakpvewb table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #vfyakpvewb thead, #vfyakpvewb tbody, #vfyakpvewb tfoot, #vfyakpvewb tr, #vfyakpvewb td, #vfyakpvewb th {
##   border-style: none;
## }
## 
## #vfyakpvewb p {
##   margin: 0;
##   padding: 0;
## }
## 
## #vfyakpvewb .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #vfyakpvewb .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #vfyakpvewb .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #vfyakpvewb .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #vfyakpvewb .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #vfyakpvewb .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #vfyakpvewb .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #vfyakpvewb .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #vfyakpvewb .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #vfyakpvewb .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #vfyakpvewb .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #vfyakpvewb .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #vfyakpvewb .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #vfyakpvewb .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #vfyakpvewb .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vfyakpvewb .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #vfyakpvewb .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #vfyakpvewb .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #vfyakpvewb .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vfyakpvewb .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #vfyakpvewb .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vfyakpvewb .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #vfyakpvewb .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vfyakpvewb .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #vfyakpvewb .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #vfyakpvewb .gt_left {
##   text-align: left;
## }
## 
## #vfyakpvewb .gt_center {
##   text-align: center;
## }
## 
## #vfyakpvewb .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #vfyakpvewb .gt_font_normal {
##   font-weight: normal;
## }
## 
## #vfyakpvewb .gt_font_bold {
##   font-weight: bold;
## }
## 
## #vfyakpvewb .gt_font_italic {
##   font-style: italic;
## }
## 
## #vfyakpvewb .gt_super {
##   font-size: 65%;
## }
## 
## #vfyakpvewb .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #vfyakpvewb .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #vfyakpvewb .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #vfyakpvewb .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #vfyakpvewb .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #vfyakpvewb .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #vfyakpvewb .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #vfyakpvewb .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #vfyakpvewb div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>DELFI score &gt; 0.4 (‘high’) versus ≤ 0.4 (‘low’) on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">DELFI_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_DELFI)
## <div id="kngvpdyoel" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#kngvpdyoel table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #kngvpdyoel thead, #kngvpdyoel tbody, #kngvpdyoel tfoot, #kngvpdyoel tr, #kngvpdyoel td, #kngvpdyoel th {
##   border-style: none;
## }
## 
## #kngvpdyoel p {
##   margin: 0;
##   padding: 0;
## }
## 
## #kngvpdyoel .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #kngvpdyoel .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #kngvpdyoel .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #kngvpdyoel .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #kngvpdyoel .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #kngvpdyoel .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #kngvpdyoel .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #kngvpdyoel .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #kngvpdyoel .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #kngvpdyoel .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #kngvpdyoel .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #kngvpdyoel .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #kngvpdyoel .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #kngvpdyoel .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #kngvpdyoel .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #kngvpdyoel .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #kngvpdyoel .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #kngvpdyoel .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #kngvpdyoel .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #kngvpdyoel .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #kngvpdyoel .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #kngvpdyoel .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #kngvpdyoel .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #kngvpdyoel .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #kngvpdyoel .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #kngvpdyoel .gt_left {
##   text-align: left;
## }
## 
## #kngvpdyoel .gt_center {
##   text-align: center;
## }
## 
## #kngvpdyoel .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #kngvpdyoel .gt_font_normal {
##   font-weight: normal;
## }
## 
## #kngvpdyoel .gt_font_bold {
##   font-weight: bold;
## }
## 
## #kngvpdyoel .gt_font_italic {
##   font-style: italic;
## }
## 
## #kngvpdyoel .gt_super {
##   font-size: 65%;
## }
## 
## #kngvpdyoel .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #kngvpdyoel .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #kngvpdyoel .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #kngvpdyoel .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #kngvpdyoel .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #kngvpdyoel .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #kngvpdyoel .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #kngvpdyoel .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #kngvpdyoel div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>DELFI score &gt; 0.4 (‘high’) versus ≤ 0.4 (‘low’) on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">DELFI_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

2.1.0.17 Univariate Cox regression analysis for cfDNA levels

library(dplyr)
library(survival)
library(gtsummary)

# 1) Build binary from the numeric column `cfDNA_Level_Baseline_ng_ml`
ClinicData <- ClinicData %>%
  mutate(
    cfDNA_Level_Baseline_binary =
      ifelse(as.numeric(cfDNA_Level_Baseline_ng_ml) > 1200, "high", "low"),
    cfDNA_Level_Baseline_binary =
      factor(cfDNA_Level_Baseline_binary, levels = c("low","high"))  # 'low' ref
  )

# 2) Cox models
label_OS  <- "Effect of Plasma cfDNA level (ng/mL) > 1200 ('high') versus ≤ 1200 ('low') on OS"
label_PFS <- "Effect of Plasma cfDNA level (ng/mL) > 1200 ('high') versus ≤ 1200 ('low') on PFS"

cox_model_OS_cfDNAlevels <-
  coxph(Surv(Time_OS, OS_Status) ~ cfDNA_Level_Baseline_binary, data = ClinicData) |>
  tbl_regression(exp = TRUE) |>
  modify_header(label = label_OS)

cox_model_PFS_cfDNAlevels <-
  coxph(Surv(Time_PFS, PFS_Status) ~ cfDNA_Level_Baseline_binary, data = ClinicData) |>
  tbl_regression(exp = TRUE) |>
  modify_header(label = label_PFS)

# 3) Print results
print(cox_model_OS_cfDNAlevels)
## <div id="khnpzezqeu" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#khnpzezqeu table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #khnpzezqeu thead, #khnpzezqeu tbody, #khnpzezqeu tfoot, #khnpzezqeu tr, #khnpzezqeu td, #khnpzezqeu th {
##   border-style: none;
## }
## 
## #khnpzezqeu p {
##   margin: 0;
##   padding: 0;
## }
## 
## #khnpzezqeu .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #khnpzezqeu .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #khnpzezqeu .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #khnpzezqeu .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #khnpzezqeu .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #khnpzezqeu .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #khnpzezqeu .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #khnpzezqeu .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #khnpzezqeu .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #khnpzezqeu .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #khnpzezqeu .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #khnpzezqeu .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #khnpzezqeu .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #khnpzezqeu .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #khnpzezqeu .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #khnpzezqeu .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #khnpzezqeu .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #khnpzezqeu .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #khnpzezqeu .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #khnpzezqeu .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #khnpzezqeu .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #khnpzezqeu .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #khnpzezqeu .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #khnpzezqeu .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #khnpzezqeu .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #khnpzezqeu .gt_left {
##   text-align: left;
## }
## 
## #khnpzezqeu .gt_center {
##   text-align: center;
## }
## 
## #khnpzezqeu .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #khnpzezqeu .gt_font_normal {
##   font-weight: normal;
## }
## 
## #khnpzezqeu .gt_font_bold {
##   font-weight: bold;
## }
## 
## #khnpzezqeu .gt_font_italic {
##   font-style: italic;
## }
## 
## #khnpzezqeu .gt_super {
##   font-size: 65%;
## }
## 
## #khnpzezqeu .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #khnpzezqeu .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #khnpzezqeu .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #khnpzezqeu .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #khnpzezqeu .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #khnpzezqeu .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #khnpzezqeu .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #khnpzezqeu .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #khnpzezqeu div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of Plasma cfDNA level (ng/mL) &gt; 1200 (‘high’) versus ≤ 1200 (‘low’) on OS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">cfDNA_Level_Baseline_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">1.10</td>
## <td headers="conf.low" class="gt_row gt_center">0.74, 1.65</td>
## <td headers="p.value" class="gt_row gt_center">0.6</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>
print(cox_model_PFS_cfDNAlevels)
## <div id="holiodycts" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
##   <style>#holiodycts table {
##   font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
##   -webkit-font-smoothing: antialiased;
##   -moz-osx-font-smoothing: grayscale;
## }
## 
## #holiodycts thead, #holiodycts tbody, #holiodycts tfoot, #holiodycts tr, #holiodycts td, #holiodycts th {
##   border-style: none;
## }
## 
## #holiodycts p {
##   margin: 0;
##   padding: 0;
## }
## 
## #holiodycts .gt_table {
##   display: table;
##   border-collapse: collapse;
##   line-height: normal;
##   margin-left: auto;
##   margin-right: auto;
##   color: #333333;
##   font-size: 16px;
##   font-weight: normal;
##   font-style: normal;
##   background-color: #FFFFFF;
##   width: auto;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #A8A8A8;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #A8A8A8;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
## }
## 
## #holiodycts .gt_caption {
##   padding-top: 4px;
##   padding-bottom: 4px;
## }
## 
## #holiodycts .gt_title {
##   color: #333333;
##   font-size: 125%;
##   font-weight: initial;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-color: #FFFFFF;
##   border-bottom-width: 0;
## }
## 
## #holiodycts .gt_subtitle {
##   color: #333333;
##   font-size: 85%;
##   font-weight: initial;
##   padding-top: 3px;
##   padding-bottom: 5px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-color: #FFFFFF;
##   border-top-width: 0;
## }
## 
## #holiodycts .gt_heading {
##   background-color: #FFFFFF;
##   text-align: center;
##   border-bottom-color: #FFFFFF;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #holiodycts .gt_bottom_border {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #holiodycts .gt_col_headings {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
## }
## 
## #holiodycts .gt_col_heading {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 6px;
##   padding-left: 5px;
##   padding-right: 5px;
##   overflow-x: hidden;
## }
## 
## #holiodycts .gt_column_spanner_outer {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: normal;
##   text-transform: inherit;
##   padding-top: 0;
##   padding-bottom: 0;
##   padding-left: 4px;
##   padding-right: 4px;
## }
## 
## #holiodycts .gt_column_spanner_outer:first-child {
##   padding-left: 0;
## }
## 
## #holiodycts .gt_column_spanner_outer:last-child {
##   padding-right: 0;
## }
## 
## #holiodycts .gt_column_spanner {
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: bottom;
##   padding-top: 5px;
##   padding-bottom: 5px;
##   overflow-x: hidden;
##   display: inline-block;
##   width: 100%;
## }
## 
## #holiodycts .gt_spanner_row {
##   border-bottom-style: hidden;
## }
## 
## #holiodycts .gt_group_heading {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   text-align: left;
## }
## 
## #holiodycts .gt_empty_group_heading {
##   padding: 0.5px;
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   vertical-align: middle;
## }
## 
## #holiodycts .gt_from_md > :first-child {
##   margin-top: 0;
## }
## 
## #holiodycts .gt_from_md > :last-child {
##   margin-bottom: 0;
## }
## 
## #holiodycts .gt_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   margin: 10px;
##   border-top-style: solid;
##   border-top-width: 1px;
##   border-top-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 1px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 1px;
##   border-right-color: #D3D3D3;
##   vertical-align: middle;
##   overflow-x: hidden;
## }
## 
## #holiodycts .gt_stub {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #holiodycts .gt_stub_row_group {
##   color: #333333;
##   background-color: #FFFFFF;
##   font-size: 100%;
##   font-weight: initial;
##   text-transform: inherit;
##   border-right-style: solid;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
##   padding-left: 5px;
##   padding-right: 5px;
##   vertical-align: top;
## }
## 
## #holiodycts .gt_row_group_first td {
##   border-top-width: 2px;
## }
## 
## #holiodycts .gt_row_group_first th {
##   border-top-width: 2px;
## }
## 
## #holiodycts .gt_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #holiodycts .gt_first_summary_row {
##   border-top-style: solid;
##   border-top-color: #D3D3D3;
## }
## 
## #holiodycts .gt_first_summary_row.thick {
##   border-top-width: 2px;
## }
## 
## #holiodycts .gt_last_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #holiodycts .gt_grand_summary_row {
##   color: #333333;
##   background-color: #FFFFFF;
##   text-transform: inherit;
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #holiodycts .gt_first_grand_summary_row {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-top-style: double;
##   border-top-width: 6px;
##   border-top-color: #D3D3D3;
## }
## 
## #holiodycts .gt_last_grand_summary_row_top {
##   padding-top: 8px;
##   padding-bottom: 8px;
##   padding-left: 5px;
##   padding-right: 5px;
##   border-bottom-style: double;
##   border-bottom-width: 6px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #holiodycts .gt_striped {
##   background-color: rgba(128, 128, 128, 0.05);
## }
## 
## #holiodycts .gt_table_body {
##   border-top-style: solid;
##   border-top-width: 2px;
##   border-top-color: #D3D3D3;
##   border-bottom-style: solid;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
## }
## 
## #holiodycts .gt_footnotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #holiodycts .gt_footnote {
##   margin: 0px;
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #holiodycts .gt_sourcenotes {
##   color: #333333;
##   background-color: #FFFFFF;
##   border-bottom-style: none;
##   border-bottom-width: 2px;
##   border-bottom-color: #D3D3D3;
##   border-left-style: none;
##   border-left-width: 2px;
##   border-left-color: #D3D3D3;
##   border-right-style: none;
##   border-right-width: 2px;
##   border-right-color: #D3D3D3;
## }
## 
## #holiodycts .gt_sourcenote {
##   font-size: 90%;
##   padding-top: 4px;
##   padding-bottom: 4px;
##   padding-left: 5px;
##   padding-right: 5px;
## }
## 
## #holiodycts .gt_left {
##   text-align: left;
## }
## 
## #holiodycts .gt_center {
##   text-align: center;
## }
## 
## #holiodycts .gt_right {
##   text-align: right;
##   font-variant-numeric: tabular-nums;
## }
## 
## #holiodycts .gt_font_normal {
##   font-weight: normal;
## }
## 
## #holiodycts .gt_font_bold {
##   font-weight: bold;
## }
## 
## #holiodycts .gt_font_italic {
##   font-style: italic;
## }
## 
## #holiodycts .gt_super {
##   font-size: 65%;
## }
## 
## #holiodycts .gt_footnote_marks {
##   font-size: 75%;
##   vertical-align: 0.4em;
##   position: initial;
## }
## 
## #holiodycts .gt_asterisk {
##   font-size: 100%;
##   vertical-align: 0;
## }
## 
## #holiodycts .gt_indent_1 {
##   text-indent: 5px;
## }
## 
## #holiodycts .gt_indent_2 {
##   text-indent: 10px;
## }
## 
## #holiodycts .gt_indent_3 {
##   text-indent: 15px;
## }
## 
## #holiodycts .gt_indent_4 {
##   text-indent: 20px;
## }
## 
## #holiodycts .gt_indent_5 {
##   text-indent: 25px;
## }
## 
## #holiodycts .katex-display {
##   display: inline-flex !important;
##   margin-bottom: 0.75em !important;
## }
## 
## #holiodycts div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
##   height: 0px !important;
## }
## </style>
##   <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
##   <thead>
##     <tr class="gt_col_headings">
##       <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="label"><span class='gt_from_md'>Effect of Plasma cfDNA level (ng/mL) &gt; 1200 (‘high’) versus ≤ 1200 (‘low’) on PFS</span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="estimate"><span class='gt_from_md'><strong>HR</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="conf.low"><span class='gt_from_md'><strong>95% CI</strong></span></th>
##       <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1" scope="col" id="p.value"><span class='gt_from_md'><strong>p-value</strong></span></th>
##     </tr>
##   </thead>
##   <tbody class="gt_table_body">
##     <tr><td headers="label" class="gt_row gt_left">cfDNA_Level_Baseline_binary</td>
## <td headers="estimate" class="gt_row gt_center"><br /></td>
## <td headers="conf.low" class="gt_row gt_center"><br /></td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    low</td>
## <td headers="estimate" class="gt_row gt_center">—</td>
## <td headers="conf.low" class="gt_row gt_center">—</td>
## <td headers="p.value" class="gt_row gt_center"><br /></td></tr>
##     <tr><td headers="label" class="gt_row gt_left">    high</td>
## <td headers="estimate" class="gt_row gt_center">1.18</td>
## <td headers="conf.low" class="gt_row gt_center">0.82, 1.72</td>
## <td headers="p.value" class="gt_row gt_center">0.4</td></tr>
##   </tbody>
##   <tfoot>
##     <tr class="gt_sourcenotes">
##       <td class="gt_sourcenote" colspan="4"><span class='gt_from_md'>Abbreviations: CI = Confidence Interval, HR = Hazard Ratio</span></td>
##     </tr>
##   </tfoot>
## </table>
## </div>

Summary of Univariable Cox Regression Analysis Results:

The univariable Cox regression analysis identified several significant predictors based on a p-value threshold of < 0.05. The significant predictors are as follows:

1) For Overall Survival (OS):

  • AFP Level > 400 (μg/L): p-value < 0.001
  • Response PD vs. SD: p-value < 0.001
  • BCLC: p-value = 0.005
  • PS:
    • PS1: p-value = 0.015
    • PS2: p-value < 0.001
  • HAP class:
    • HAP_classC: p-value = 0.045
    • HAP_classD: p-value = 0.007
  • PVT: p-value = 0.009
  • TF > 15%: p-value = 0.041

2) For Progression-Free Survival (PFS):

  • AFP Level > 400 (μg/L): p-value = 0.006
  • Response PD vs. SD: p-value < 0.001
  • BCLC: p-value < 0.001
  • PS:
    • PS1: p-value < 0.001
    • PS2: p-value < 0.001
  • Cirrhosis: p-value = 0.049
  • PVT: p-value < 0.001
  • TF > 15%: p-value < 0.001
  • CTP: p-value = 0.009

2.2 Multivariate analysis

#Create a List of Significant Predictors for OS
#For predictors showing significance in univariable analysis:

significant_predictors_OS <- c("AFP_binary", "BCLC", "PS", 
                             "PVT", "PS", "DELFI_binary", "cfDNA_TF_Baseline_binary","CTP")

#Create a List of Significant Predictors for PFS
#For predictors showing significance in univariable analysis:
significant_predictors_PFS <- c("AFP_binary", "BCLC", "PS", 
                             "PVT", "PS", "DELFI_binary", "cfDNA_TF_Baseline_binary","CTP")

#####Multivariable analysis#####
# Fit the multivariable Cox proportional hazards model
#Using the significant predictors identified from the univariable analysis,
#We can fit a multivariable Cox proportional hazards model:
(Final_model_OS <- coxph(Surv(Time_OS, OS_Status) ~ AFP_binary + BCLC + 
                        + PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP , data = ClinicData))
## Call:
## coxph(formula = Surv(Time_OS, OS_Status) ~ AFP_binary + BCLC + 
##     +PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP, 
##     data = ClinicData)
## 
##                                  coef exp(coef) se(coef)      z        p
## AFP_binaryhigh                1.02315   2.78194  0.25087  4.078 4.53e-05
## BCLCC                         0.77743   2.17587  0.34121  2.278   0.0227
## PS1                          -0.08683   0.91684  0.30634 -0.283   0.7769
## PS2                           0.22257   1.24928  0.47782  0.466   0.6414
## PVTYes                        0.16082   1.17448  0.33020  0.487   0.6262
## DELFI_binaryhigh                   NA        NA  0.00000     NA       NA
## cfDNA_TF_Baseline_binaryhigh  0.15499   1.16765  0.23382  0.663   0.5074
## CTPB                          0.22180   1.24833  0.31019  0.715   0.4746
## 
## Likelihood ratio test=40.08  on 7 df, p=1.217e-06
## n= 134, number of events= 100
summary(Final_model_OS)
## Call:
## coxph(formula = Surv(Time_OS, OS_Status) ~ AFP_binary + BCLC + 
##     +PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP, 
##     data = ClinicData)
## 
##   n= 134, number of events= 100 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)    
## AFP_binaryhigh                1.02315   2.78194  0.25087  4.078 4.53e-05 ***
## BCLCC                         0.77743   2.17587  0.34121  2.278   0.0227 *  
## PS1                          -0.08683   0.91684  0.30634 -0.283   0.7769    
## PS2                           0.22257   1.24928  0.47782  0.466   0.6414    
## PVTYes                        0.16082   1.17448  0.33020  0.487   0.6262    
## DELFI_binaryhigh                   NA        NA  0.00000     NA       NA    
## cfDNA_TF_Baseline_binaryhigh  0.15499   1.16765  0.23382  0.663   0.5074    
## CTPB                          0.22180   1.24833  0.31019  0.715   0.4746    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## AFP_binaryhigh                  2.7819     0.3595    1.7014     4.549
## BCLCC                           2.1759     0.4596    1.1148     4.247
## PS1                             0.9168     1.0907    0.5030     1.671
## PS2                             1.2493     0.8005    0.4897     3.187
## PVTYes                          1.1745     0.8514    0.6149     2.243
## DELFI_binaryhigh                    NA         NA        NA        NA
## cfDNA_TF_Baseline_binaryhigh    1.1676     0.8564    0.7384     1.846
## CTPB                            1.2483     0.8011    0.6797     2.293
## 
## Concordance= 0.701  (se = 0.027 )
## Likelihood ratio test= 40.08  on 7 df,   p=1e-06
## Wald test            = 41.04  on 7 df,   p=8e-07
## Score (logrank) test = 46.39  on 7 df,   p=7e-08
(Final_model_PFS <- coxph(Surv(Time_PFS, PFS_Status) ~ AFP_binary + BCLC + 
                        + PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP + Treatment_Class, data = ClinicData))
## Call:
## coxph(formula = Surv(Time_PFS, PFS_Status) ~ AFP_binary + BCLC + 
##     +PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP + 
##     Treatment_Class, data = ClinicData)
## 
##                                 coef exp(coef) se(coef)      z       p
## AFP_binaryhigh                0.4791    1.6147   0.2354  2.036 0.04177
## BCLCC                         0.8271    2.2868   0.3577  2.312 0.02077
## PS1                          -0.4217    0.6559   0.2985 -1.413 0.15779
## PS2                          -0.2744    0.7600   0.4642 -0.591 0.55443
## PVTYes                        0.6413    1.8990   0.4263  1.504 0.13247
## DELFI_binaryhigh                  NA        NA   0.0000     NA      NA
## cfDNA_TF_Baseline_binaryhigh  0.5843    1.7937   0.2192  2.666 0.00769
## CTPB                          0.4317    1.5399   0.2958  1.460 0.14439
## Treatment_ClassICI           -0.1130    0.8932   0.2875 -0.393 0.69445
## 
## Likelihood ratio test=53.14  on 8 df, p=1.014e-08
## n= 134, number of events= 114
summary(Final_model_PFS)
## Call:
## coxph(formula = Surv(Time_PFS, PFS_Status) ~ AFP_binary + BCLC + 
##     +PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP + 
##     Treatment_Class, data = ClinicData)
## 
##   n= 134, number of events= 114 
## 
##                                 coef exp(coef) se(coef)      z Pr(>|z|)   
## AFP_binaryhigh                0.4791    1.6147   0.2354  2.036  0.04177 * 
## BCLCC                         0.8271    2.2868   0.3577  2.312  0.02077 * 
## PS1                          -0.4217    0.6559   0.2985 -1.413  0.15779   
## PS2                          -0.2744    0.7600   0.4642 -0.591  0.55443   
## PVTYes                        0.6413    1.8990   0.4263  1.504  0.13247   
## DELFI_binaryhigh                  NA        NA   0.0000     NA       NA   
## cfDNA_TF_Baseline_binaryhigh  0.5843    1.7937   0.2192  2.666  0.00769 **
## CTPB                          0.4317    1.5399   0.2958  1.460  0.14439   
## Treatment_ClassICI           -0.1130    0.8932   0.2875 -0.393  0.69445   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## AFP_binaryhigh                  1.6147     0.6193    1.0180     2.561
## BCLCC                           2.2868     0.4373    1.1342     4.610
## PS1                             0.6559     1.5245    0.3654     1.178
## PS2                             0.7600     1.3157    0.3060     1.888
## PVTYes                          1.8990     0.5266    0.8235     4.379
## DELFI_binaryhigh                    NA         NA        NA        NA
## cfDNA_TF_Baseline_binaryhigh    1.7937     0.5575    1.1673     2.756
## CTPB                            1.5399     0.6494    0.8624     2.750
## Treatment_ClassICI              0.8932     1.1196    0.5084     1.569
## 
## Concordance= 0.71  (se = 0.024 )
## Likelihood ratio test= 53.14  on 8 df,   p=1e-08
## Wald test            = 51.03  on 8 df,   p=3e-08
## Score (logrank) test = 56.58  on 8 df,   p=2e-09
(cox <- coxph(Surv(Time_OS, OS_Status) ~ AFP_binary + BCLC + 
                        + PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP, data = ClinicData) %>%
    tbl_regression(exp = TRUE))
Characteristic HR 95% CI p-value
AFP_binary


    low
    high 2.78 1.70, 4.55 <0.001
BCLC


    B
    C 2.18 1.11, 4.25 0.023
PS


    0
    1 0.92 0.50, 1.67 0.8
    2 1.25 0.49, 3.19 0.6
PVT


    No
    Yes 1.17 0.61, 2.24 0.6
DELFI_binary


    low
    high


cfDNA_TF_Baseline_binary


    low
    high 1.17 0.74, 1.85 0.5
CTP


    A
    B 1.25 0.68, 2.29 0.5
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
(cox <- coxph(Surv(Time_PFS, PFS_Status) ~ AFP_binary + BCLC + 
                        + PS + PVT + DELFI_binary + cfDNA_TF_Baseline_binary + CTP + Treatment_Class, data = ClinicData) %>%
    tbl_regression(exp = TRUE))
Characteristic HR 95% CI p-value
AFP_binary


    low
    high 1.61 1.02, 2.56 0.042
BCLC


    B
    C 2.29 1.13, 4.61 0.021
PS


    0
    1 0.66 0.37, 1.18 0.2
    2 0.76 0.31, 1.89 0.6
PVT


    No
    Yes 1.90 0.82, 4.38 0.13
DELFI_binary


    low
    high


cfDNA_TF_Baseline_binary


    low
    high 1.79 1.17, 2.76 0.008
CTP


    A
    B 1.54 0.86, 2.75 0.14
Treatment_Class


    TKI
    ICI 0.89 0.51, 1.57 0.7
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio
#Check the proportional hazards assumption
#We can check the proportional hazards assumption for the final model using the cox.zph function:
ph_test_OS <- cox.zph(Final_model_OS)
print(ph_test_OS)
##                            chisq df       p
## AFP_binary                0.0404  1 0.84076
## BCLC                      2.7314  1 0.09839
## PS                        1.4897  2 0.47480
## PVT                       0.0162  1 0.89859
## cfDNA_TF_Baseline_binary 12.5557  1 0.00039
## CTP                       0.0699  1 0.79150
## GLOBAL                   18.3264  7 0.01058
ph_test_PFS <- cox.zph(Final_model_PFS)
print(ph_test_PFS)
##                           chisq df      p
## AFP_binary                0.305  1 0.5810
## BCLC                      1.786  1 0.1814
## PS                        2.437  2 0.2956
## PVT                       0.315  1 0.5745
## cfDNA_TF_Baseline_binary  7.312  1 0.0068
## CTP                       1.255  1 0.2627
## Treatment_Class           1.599  1 0.2060
## GLOBAL                   14.494  8 0.0698
# Fit the Cox proportional hazards model
cox_model_Age <- coxph(Surv(ClinicData$Age, ClinicData$OS_Status) ~ Age, data = ClinicData)

# Display the model summary
summary(cox_model_Age)
## Call:
## coxph(formula = Surv(ClinicData$Age, ClinicData$OS_Status) ~ 
##     Age, data = ClinicData)
## 
##   n= 134, number of events= 100 
## 
##           coef  exp(coef)   se(coef)     z Pr(>|z|)
## Age -1.756e+01  2.369e-08  5.885e+02 -0.03    0.976
## 
##     exp(coef) exp(-coef) lower .95 upper .95
## Age 2.369e-08   42214101         0       Inf
## 
## Concordance= 0.992  (se = 0.002 )
## Likelihood ratio test= 560.4  on 1 df,   p=<2e-16
## Wald test            = 0  on 1 df,   p=1
## Score (logrank) test = 227.9  on 1 df,   p=<2e-16

The coefficient: in a statistical model,like the Cox proportional hazards model, represents the effect of a variable (e.g., Age) on the outcome (e.g., risk of death), where a negative coefficient suggests that as the variable increases, the risk decreases and versa.

Hazard Ratio (exp(coef)): for Age: is approximately 2.54e-08, which is an extremely small value, indicating that the risk of death decreases significantly with each additional year of age. However, this value is so small that it might not be realistic or interpretable in a practical sense.

Standard Error (se(coef)): The standard error of the coefficient is very large (approximately 719.7), suggesting a high degree of uncertainty in the estimate of the coefficient for Age.

The z-score is -0.024, and p-value is 0.981. The very high p-value indicates that the coefficient for Age is not statistically significant. This means that we cannot conclude that Age has a significant effect on the risk of death based on this model.

The confidence interval for the hazard ratio ranges from 0 to infinity. This extremely wide interval further indicates a high degree of uncertainty and suggests that the model is not providing a precise estimate of the effect of Age on the risk of death.

The concordance statistic is 0.995, which suggests that the model has a very high ability to correctly rank the risk of death between patients. However, given the other statistics, this might not be reliable.

The likelihood ratio test and score (logrank) test have very low p-values (<2e-16), suggesting that the model overall is statistically significant. The Wald test, however, has a p-value of 1, indicating that the coefficient for Age itself is not statistically significant.